From 145a8d6690b117a65efc7fa3fb4afced71cd4a07 Mon Sep 17 00:00:00 2001 From: Jainish Shah Date: Wed, 13 Jun 2018 12:15:28 -0700 Subject: [PATCH] Adding JFrog Distribution (#5631) * added JFrog Distribution * Fixed version * removed extra empty line * using secret for connection string * removed unused condition * chart.name from template * removed resource value and added new apiVersion * removed extra spaces * removed default token * fullnameOverride for distribution * removed unused condition. * Changing default external port to 80 * removed post install hook. * removed hardcoded password and made it required * added token for testing * removed non overriding values --- incubator/distribution/.helmignore | 21 +++ incubator/distribution/Chart.yaml | 18 +++ incubator/distribution/README.md | 99 ++++++++++++ incubator/distribution/ci/test-values.yaml | 12 ++ incubator/distribution/requirements.lock | 9 ++ incubator/distribution/requirements.yaml | 9 ++ incubator/distribution/templates/NOTES.txt | 27 ++++ incubator/distribution/templates/_helpers.tpl | 87 ++++++++++ .../templates/distribution-deployment.yaml | 116 ++++++++++++++ .../templates/distribution-pvc.yaml | 24 +++ .../templates/distribution-svc.yaml | 24 +++ .../templates/distributor-deployment.yaml | 91 +++++++++++ .../templates/distributor-pvc.yaml | 24 +++ .../templates/distributor-token.yaml | 14 ++ .../templates/mongo-connection-secret.yaml | 15 ++ .../templates/redis-connection-secret.yaml | 14 ++ incubator/distribution/values.yaml | 149 ++++++++++++++++++ 17 files changed, 753 insertions(+) create mode 100644 incubator/distribution/.helmignore create mode 100644 incubator/distribution/Chart.yaml create mode 100644 incubator/distribution/README.md create mode 100644 incubator/distribution/ci/test-values.yaml create mode 100644 incubator/distribution/requirements.lock create mode 100644 incubator/distribution/requirements.yaml create mode 100644 incubator/distribution/templates/NOTES.txt create mode 100644 incubator/distribution/templates/_helpers.tpl create mode 100644 incubator/distribution/templates/distribution-deployment.yaml create mode 100644 incubator/distribution/templates/distribution-pvc.yaml create mode 100644 incubator/distribution/templates/distribution-svc.yaml create mode 100644 incubator/distribution/templates/distributor-deployment.yaml create mode 100644 incubator/distribution/templates/distributor-pvc.yaml create mode 100644 incubator/distribution/templates/distributor-token.yaml create mode 100644 incubator/distribution/templates/mongo-connection-secret.yaml create mode 100644 incubator/distribution/templates/redis-connection-secret.yaml create mode 100644 incubator/distribution/values.yaml diff --git a/incubator/distribution/.helmignore b/incubator/distribution/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/incubator/distribution/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/incubator/distribution/Chart.yaml b/incubator/distribution/Chart.yaml new file mode 100644 index 0000000000..117f56f482 --- /dev/null +++ b/incubator/distribution/Chart.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +description: A Helm chart for JFrog Distribution +home: https://jfrog.com/platform/ +icon: https://raw.githubusercontent.com/JFrogDev/artifactory-dcos/master/images/jfrog_med.png +keywords: +- distribution +- jfrog +maintainers: +- email: jainishs@jfrog.com + name: jainishshah17 +- email: eldada@jfrog.com + name: eldada +name: distribution +sources: +- https://bintray.com/jfrog/product/distribution/view +- https://github.com/JFrogDev +version: 0.3.0 +appVersion: 1.0.0 diff --git a/incubator/distribution/README.md b/incubator/distribution/README.md new file mode 100644 index 0000000000..b3ea7a227c --- /dev/null +++ b/incubator/distribution/README.md @@ -0,0 +1,99 @@ +# JFrog Distribution Helm Chart + +## Prerequisites Details + +* Kubernetes 1.8+ + +## Chart Details +This chart will do the following: + +* Deploy Mongodb database. +* Deploy a Redis. +* Deploy a distributor. +* Deploy a distribution. + +## Requirements +- A running Kubernetes cluster +- Dynamic storage provisioning enabled +- Default StorageClass set to allow services using the default StorageClass for persistent storage +- A running Artifactory Enterprise Plus +- [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) installed and setup to use the cluster +- [Helm](https://helm.sh/) installed and setup to use the cluster (helm init) + +## Installing the Chart +To install the chart with the release name `distribution`: +``` +helm install --name distribution incubator/distribution +``` + +### Accessing Distribution +**NOTE:** It might take a few minutes for Distribution's public IP to become available, and the nodes to complete initial setup. +Follow the instructions outputted by the install command to get the Distribution IP and URL to access it. + +### Updating Distribution +Once you have a new chart version, you can update your deployment with +``` +helm upgrade distribution incubator/distribution +``` + +## Configuration + +The following table lists the configurable parameters of the distribution chart and their default values. + +| Parameter | Description | Default | +|----------------------------------------------|--------------------------------------------|------------------------------------| +| `imagePullSecrets` | Docker registry pull secret | | +| `mongodb.enabled` | Enable Mongodb | `true` | +| `mongodb.image.tag` | Mongodb docker image tag | `3.6.3` | +| `mongodb.image.pullPolicy` | Mongodb Container pull policy | `IfNotPresent` | +| `mongodb.persistence.enabled` | Mongodb persistence volume enabled | `true` | +| `mongodb.persistence.existingClaim` | Use an existing PVC to persist data | `nil` | +| `mongodb.persistence.storageClass` | Storage class of backing PVC | `generic` | +| `mongodb.persistence.size` | Mongodb persistence volume size | `10Gi` | +| `mongodb.livenessProbe.initialDelaySeconds` | Mongodb delay before liveness probe is initiated | `40` | +| `mongodb.readinessProbe.initialDelaySeconds` | Mongodb delay before readiness probe is initiated | `30` | +| `mongodb.mongodbExtraFlags` | MongoDB additional command line flags | `["--wiredTigerCacheSizeGB=1"]` | +| `mongodb.usePassword` | Enable password authentication | `false` | +| `mongodb.mongodbDatabase` | Mongodb Database for distribution | `bintray` | +| `mongodb.mongodbRootPassword` | Mongodb Database Password for root user | ` ` | +| `mongodb.mongodbUsername` | Mongodb Database Mission Control User | `distribution` | +| `mongodb.mongodbPassword` | Mongodb Database Password for Mission Control user | ` ` | +| `redis.enabled` | Enable Redis | `true` | +| `redis.redisPassword` | Redis password | ` ` | +| `redis.master.port` | Redis Port | `6379` | +| `redis.persistence.enabled` | Use a PVC to persist data | `true` | +| `redis.persistence.existingClaim` | Use an existing PVC to persist data | `nil` | +| `redis.persistence.storageClass` | Storage class of backing PVC | `generic` | +| `redis.persistence.size` | Size of data volume | `10Gi` | +| `distribution.name` | Distribution name | `distribution` | +| `distribution.image.pullPolicy` | Container pull policy | `IfNotPresent` | +| `distribution.image.repository` | Container image | `docker.jfrog.io/jf-distribution` | +| `distribution.image.version` | Container image tag | `1.0.0` | +| `distribution.service.type` | Distribution service type | `LoadBalancer` | +| `distribution.externalPort` | Distribution service external port | `80` | +| `distribution.internalPort` | Distribution service internal port | `8080` | +| `distribution.env.artifactoryUrl` | Distribution Environment Artifactory URL | ` ` | +| `distribution.persistence.mountPath` | Distribution persistence volume mount path | `"/jf-distribution"` | +| `distribution.persistence.enabled` | Distribution persistence volume enabled | `true` | +| `distribution.persistence.storageClass` | Storage class of backing PVC | `nil` | +| `distribution.persistence.existingClaim` | Provide an existing PersistentVolumeClaim | `nil` | +| `distribution.persistence.accessMode` | Distribution persistence volume access mode| `ReadWriteOnce` | +| `distribution.persistence.size` | Distribution persistence volume size | `50Gi` | +| `distributor.name` | Distribution name | `distribution` | +| `distributor.image.pullPolicy` | Container pull policy | `IfNotPresent` | +| `distributor.image.repository` | Container image | `docker.jfrog.io/jf-distribution` | +| `distributor.image.version` | Container image tag | `1.0.0` | +| `distributor.token` | Distributor token | ` ` | +| `distributor.persistence.mountPath` | Distributor persistence volume mount path | `"/bt-distributor"` | +| `distributor.persistence.existingClaim` | Provide an existing PersistentVolumeClaim | `nil` | +| `distributor.persistence.storageClass` | Storage class of backing PVC | `nil (uses alpha storage class annotation)` | +| `distributor.persistence.enabled` | Distributor persistence volume enabled | `true` | +| `distributor.persistence.accessMode` | Distributor persistence volume access mode | `ReadWriteOnce` | +| `distributor.persistence.size` | Distributor persistence volume size | `50Gi` | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. + +## Useful links +- https://www.jfrog.com/confluence/display/EP/Getting+Started +- https://www.jfrog.com/confluence/display/DIST/Installing+Distribution +- https://www.jfrog.com/confluence/ diff --git a/incubator/distribution/ci/test-values.yaml b/incubator/distribution/ci/test-values.yaml new file mode 100644 index 0000000000..6e1f4038ce --- /dev/null +++ b/incubator/distribution/ci/test-values.yaml @@ -0,0 +1,12 @@ +# CI values for Distribution + + +mongodb: + mongodbRootPassword: password + mongodbPassword: password + +redis: + redisPassword: "password" + +distributor: + token: "eyJ2ZXIiOiIyIiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYiLCJraWQiOiJ6WWFWQjVFRlpkOXlpbWtCNkZTbDAtSWFhMHRPWldLX293c1BTVTNTZmdNIn0.eyJzdWIiOiJJTlRFUk5BTCIsInNjcCI6ImFwcGxpZWQtcGVybWlzc2lvbnNcL3N5c3RlbSIsImF1ZCI6ImpmZHNAMDFjN3pxd2FnOWNmNTAwd2FnOXZhcTF3cjkiLCJpc3MiOiJqZmRzQDAxYzd6cXdhZzljZjUwMHdhZzl2YXExd3I5IiwiZXhwIjoyNDY3NjI1MDczLCJpYXQiOjE1MjE1NDUwNzMsImp0aSI6IjE0ZjJjN2IxLTMzYzQtNDA0Yy04YTllLTJmZjU2OGFjODRlOSJ9.ACfT3pfu4wTTt1wOkyqwYCp9UUVWNwMLl3ZyuO-igDR9N_G-G3oMkuCFekAzgOrTcbGjrXTDMNwoRyYhHUs4wtYxM9yAA-u72EhVz10stL9B0d2JUOamc8xJaLvQDhL38TYiTjdgNVsy726qgxzX2xnx1M8VSp9Qnw7r2ZGBQ6LjrESIUZb8IXy-93oxYqDSkWvjOJZiNQXhJBgOzhzq3r-buaGgxOMoC7DduCctCT0FIxd1jrsZPUnpH3YGE374j7YGcGBdy7eQj-skM3YircJVgk6XFYJBKZBJ8pX3NLZznirG2m9QbhLCRhH1T6B4g-HZvy251wz3QBUdmzO6Cg" diff --git a/incubator/distribution/requirements.lock b/incubator/distribution/requirements.lock new file mode 100644 index 0000000000..70dc3e6904 --- /dev/null +++ b/incubator/distribution/requirements.lock @@ -0,0 +1,9 @@ +dependencies: +- name: mongodb + repository: https://kubernetes-charts.storage.googleapis.com/ + version: 2.0.5 +- name: redis + repository: https://kubernetes-charts.storage.googleapis.com/ + version: 1.1.21 +digest: sha256:beb9912728c7d372ddc2ba5b5c4dcee718bd78f65219c1d6831377aad227d471 +generated: 2018-05-11T08:38:33.357628483-07:00 diff --git a/incubator/distribution/requirements.yaml b/incubator/distribution/requirements.yaml new file mode 100644 index 0000000000..9bbfcea576 --- /dev/null +++ b/incubator/distribution/requirements.yaml @@ -0,0 +1,9 @@ +dependencies: +- name: mongodb + version: 2.0.5 + repository: https://kubernetes-charts.storage.googleapis.com/ + condition: mongodb.enabled +- name: redis + version: 1.1.21 + repository: https://kubernetes-charts.storage.googleapis.com/ + condition: redis.enabled \ No newline at end of file diff --git a/incubator/distribution/templates/NOTES.txt b/incubator/distribution/templates/NOTES.txt new file mode 100644 index 0000000000..364bb6dba6 --- /dev/null +++ b/incubator/distribution/templates/NOTES.txt @@ -0,0 +1,27 @@ +Congratulations. You have just deployed JFrog Distribution! + +1. Get the Distribution URL by running these commands: + + {{- if contains "NodePort" .Values.distribution.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "distribution.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT/ + + {{- else if contains "LoadBalancer" .Values.distribution.service.type }} + + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of the service by running 'kubectl get svc -w {{ template "distribution.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "distribution.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.distribution.externalPort }}/ + + {{- else if contains "ClusterIP" .Values.distribution.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "component={{ .Values.distribution.name }}" -o jsonpath="{.items[0].metadata.name}") + echo http://127.0.0.1:{{ .Values.distribution.externalPort }} + kubectl port-forward --namespace {{ .Release.Namespace }} $POD_NAME {{ .Values.distribution.externalPort }}:{{ .Values.distribution.internalPort }} + + {{- end }} + +2. Open Distribution in your browser + Default credential for Distribution: + user: admin + password: password diff --git a/incubator/distribution/templates/_helpers.tpl b/incubator/distribution/templates/_helpers.tpl new file mode 100644 index 0000000000..516b8ae80e --- /dev/null +++ b/incubator/distribution/templates/_helpers.tpl @@ -0,0 +1,87 @@ +{{/* vim: set filetype=mustache: */}} + +{{/* +Expand the name of the chart. +*/}} +{{- define "distribution.name" -}} +{{- default .Chart.Name .Values.distribution.name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +The distributor name +*/}} +{{- define "distributor.name" -}} +{{- default .Chart.Name .Values.distributor.name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified distribution name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "distribution.fullname" -}} +{{- if .Values.distribution.fullnameOverride -}} +{{- .Values.distribution.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.distribution.name -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + + +{{/* +Create a default fully qualified distributor name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "distributor.fullname" -}} +{{- if .Values.distributor.fullnameOverride -}} +{{- .Values.distributor.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.distributor.name -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Set the final MongoDB connection URL +*/}} +{{- define "mongodb.url" -}} +{{- $mongoDatabase := .Values.mongodb.mongodbDatabase -}} +{{- $mongoUser := .Values.mongodb.mongodbUsername -}} +{{- $mongoPassword := required "A valid .Values.mongodb.mongodbPassword entry required!" .Values.mongodb.mongodbPassword -}} +{{- printf "%s://%s:%s@%s-%s/%s" "mongodb" $mongoUser $mongoPassword .Release.Name "mongodb:27017" $mongoDatabase | b64enc | quote -}} +{{- end -}} + +{{/* +Set the final MongoDB audit URL +*/}} +{{- define "mongodb.audit.url" -}} +{{- $mongoUser := .Values.mongodb.mongodbUsername -}} +{{- $mongoPassword := required "A valid .Values.mongodb.mongodbPassword entry required!" .Values.mongodb.mongodbPassword -}} +{{- printf "%s://%s:%s@%s-%s/%s" "mongodb" $mongoUser $mongoPassword .Release.Name "mongodb:27017" "audit?maxpoolsize=500" | b64enc | quote -}} +{{- end -}} + +{{/* +Set the final Redis connection URL +*/}} +{{- define "redis.url" -}} +{{- $redisPassword := required "A valid .Values.redis.redisPassword entry required!" .Values.redis.redisPassword -}} +{{- $redisPort := .Values.redis.master.port -}} +{{- printf "%s://:%s@%s-%s:%g" "redis" $redisPassword .Release.Name "redis" $redisPort | b64enc | quote -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "distribution.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/incubator/distribution/templates/distribution-deployment.yaml b/incubator/distribution/templates/distribution-deployment.yaml new file mode 100644 index 0000000000..4edc37c7ff --- /dev/null +++ b/incubator/distribution/templates/distribution-deployment.yaml @@ -0,0 +1,116 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "distribution.fullname" . }} + labels: + app: {{ template "distribution.name" . }} + chart: {{ template "distribution.chart" . }} + component: {{ .Values.distribution.name }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +spec: + replicas: {{ .Values.distribution.replicaCount }} + selector: + matchLabels: + app: {{ template "distribution.name" . }} + release: {{ .Release.Name }} + component: {{ .Values.distribution.name }} + template: + metadata: + labels: + app: {{ template "distribution.name" . }} + component: {{ .Values.distribution.name }} + release: {{ .Release.Name }} + spec: + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + - name: {{ .Values.imagePullSecrets }} + {{- end }} + initContainers: + - name: "init-data" + image: "{{ .Values.initContainerImage }}" + command: + - '/bin/sh' + - '-c' + - > + until nc -z -w 2 {{ .Release.Name }}-mongodb 27017 && echo {{ .Release.Name }}-mongodb ok; do sleep 2; done; + until nc -z -w 2 {{ .Release.Name }}-redis {{ .Values.redis.master.port }} && echo {{ .Release.Name }}-redis ok; do sleep 2; done; + containers: + - name: {{ .Values.distribution.name }} + image: '{{ .Values.distribution.image.repository }}:{{ .Values.distribution.image.version }}' + imagePullPolicy: {{ .Values.distribution.image.imagePullPolicy }} + ports: + - containerPort: {{ .Values.distribution.internalPort }} + protocol: TCP + env: + - name: DEFAULT_JAVA_OPTS + value: '-Ddistribution.home={{ .Values.distribution.persistence.mountPath }} -Dcom.sun.management.jmxremote.authenticate=false + -Dcom.sun.management.jmxremote.ssl=false -Duser.timezone=UTC + {{- if .Values.distribution.javaOpts.xms }} + -Xms{{ .Values.distribution.javaOpts.xms }} + {{- end}} + {{- if .Values.distribution.javaOpts.xmx }} + -Xmx{{ .Values.distribution.javaOpts.xmx }} + {{- end}} + -Dspring.profiles.active=production' + - name: mongo_connectionString + valueFrom: + secretKeyRef: + name: {{ template "distribution.fullname" . }}-mongo-connection + key: mongo_connectionString + - name: audit_mongo_connectionString + valueFrom: + secretKeyRef: + name: {{ template "distribution.fullname" . }}-mongo-connection + key: audit_mongo_connectionString + - name: redis_connectionString + valueFrom: + secretKeyRef: + name: {{ template "distribution.fullname" . }}-redis-connection + key: redis_connectionString + - name: BT_ARTIFACTORY_URL + value: {{ .Values.distribution.env.artifactoryUrl | quote }} + - name: BT_SERVER_URL + value: {{ .Values.distribution.env.btServerUrl | quote }} + {{- if .Values.distribution.env.artifactoryEdge1Url }} + - name: artifactory_edge_1_url + value: {{ .Values.distribution.env.artifactoryEdge1Url }} + {{- end }} + {{- if .Values.distribution.env.artifactoryEdge2Url }} + - name: artifactory_edge_2_url + value: {{ .Values.distribution.env.artifactoryEdge2Url }} + {{- end }} + {{- if .Values.distribution.env.artifactoryEdge3Url }} + - name: artifactory_edge_3_url + value: {{ .Values.distribution.env.artifactoryEdge3Url }} + {{- end }} + {{- if .Values.distribution.env.artifactoryCi1Url }} + - name: artifactory_ci_1_url + value: {{ .Values.distribution.env.artifactoryCi1Url }} + {{- end }} + volumeMounts: + - name: distribution-data + mountPath: {{ .Values.distribution.persistence.mountPath | quote }} + resources: +{{ toYaml .Values.distribution.resources | indent 10 }} + readinessProbe: + httpGet: + path: /api/v1/system/ping + port: 8080 + initialDelaySeconds: 60 + periodSeconds: 10 + failureThreshold: 10 + livenessProbe: + httpGet: + path: /api/v1/system/ping + port: 8080 + initialDelaySeconds: 180 + periodSeconds: 10 + volumes: + - name: distribution-data + {{- if .Values.distribution.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ if .Values.distribution.persistence.existingClaim }}{{ .Values.distribution.persistence.existingClaim }}{{- else }}{{ template "distribution.fullname" . }}{{- end }} + {{- else }} + emptyDir: {} + {{- end -}} diff --git a/incubator/distribution/templates/distribution-pvc.yaml b/incubator/distribution/templates/distribution-pvc.yaml new file mode 100644 index 0000000000..32648105b4 --- /dev/null +++ b/incubator/distribution/templates/distribution-pvc.yaml @@ -0,0 +1,24 @@ +{{- if and .Values.distribution.persistence.enabled (not .Values.distribution.persistence.existingClaim) }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ template "distribution.fullname" . }} + labels: + app: {{ template "distribution.name" . }} + chart: {{ template "distribution.chart" . }} + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + accessModes: + - {{ .Values.distribution.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.distribution.persistence.size }} +{{- if .Values.distribution.persistence.storageClass }} +{{- if (eq "-" .Values.distribution.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.distribution.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end }} diff --git a/incubator/distribution/templates/distribution-svc.yaml b/incubator/distribution/templates/distribution-svc.yaml new file mode 100644 index 0000000000..654510f0a8 --- /dev/null +++ b/incubator/distribution/templates/distribution-svc.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "distribution.fullname" . }} + labels: + app: {{ template "distribution.name" . }} + chart: {{ template "distribution.chart" . }} + component: "{{ .Values.distribution.name }}" + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +{{- if .Values.distribution.service.annotations }} + annotations: +{{ toYaml .Values.distribution.service.annotations | indent 4 }} +{{- end }} +spec: + type: {{ .Values.distribution.service.type }} + ports: + - port: {{ .Values.distribution.externalPort }} + protocol: TCP + targetPort: {{ .Values.distribution.internalPort }} + selector: + app: {{ template "distribution.name" . }} + component: "{{ .Values.distribution.name }}" + release: {{ .Release.Name }} diff --git a/incubator/distribution/templates/distributor-deployment.yaml b/incubator/distribution/templates/distributor-deployment.yaml new file mode 100644 index 0000000000..2e4f56f6d5 --- /dev/null +++ b/incubator/distribution/templates/distributor-deployment.yaml @@ -0,0 +1,91 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "distributor.fullname" . }} + labels: + app: {{ template "distribution.name" . }} + chart: {{ template "distribution.chart" . }} + component: {{ .Values.distributor.name }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +spec: + replicas: {{ .Values.distributor.replicaCount }} + selector: + matchLabels: + app: {{ template "distribution.name" . }} + release: {{ .Release.Name }} + component: {{ .Values.distributor.name }} + template: + metadata: + labels: + app: {{ template "distribution.name" . }} + component: {{ .Values.distributor.name }} + release: {{ .Release.Name }} + spec: + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + - name: {{ .Values.imagePullSecrets }} + {{- end }} + initContainers: + - name: "prepare-data" + image: "{{ .Values.initContainerImage }}" + imagePullPolicy: {{ .Values.distributor.image.pullPolicy }} + command: + - '/bin/sh' + - '-c' + - > + until nc -z -w 2 {{ .Release.Name }}-redis {{ .Values.redis.master.port }} && echo {{ .Release.Name }}-redis ok; do sleep 2; done; + {{- if .Values.distributor.token }} + mkdir -pv {{ .Values.distributor.persistence.mountPath }}/etc/security; + cp -fv /tmp/security/token {{ .Values.distributor.persistence.mountPath }}/etc/security/token; + chmod 400 {{ .Values.distributor.persistence.mountPath }}/etc/security/token; + {{- end }} + chown -R 1020:1020 {{ .Values.distributor.persistence.mountPath }} + volumeMounts: + - name: distributor-data + mountPath: {{ .Values.distributor.persistence.mountPath | quote }} + {{- if .Values.distributor.token }} + - name: distributor-token + mountPath: "/tmp/security/token" + subPath: token + {{- end }} + containers: + - name: {{ .Values.distributor.name }} + image: '{{ .Values.distributor.image.repository }}:{{ .Values.distributor.image.version }}' + imagePullPolicy: {{ .Values.distributor.image.imagePullPolicy }} + env: + - name: DEFAULT_JAVA_OPTS + value: '-Ddistribution.home={{ .Values.distributor.persistence.mountPath }} -Dfile.encoding=UTF8 -Dcom.sun.management.jmxremote.authenticate=false + -Dcom.sun.management.jmxremote.ssl=false -Duser.timezone=UTC + {{- if .Values.distributor.javaOpts.xms }} + -Xms{{ .Values.distributor.javaOpts.xms }} + {{- end}} + {{- if .Values.distributor.javaOpts.xmx }} + -Xmx{{ .Values.distributor.javaOpts.xmx }} + {{- end}} + -Dspring.profiles.active=production' + - name: redis_connectionString + valueFrom: + secretKeyRef: + name: {{ template "distribution.fullname" . }}-redis-connection + key: redis_connectionString + - name: BT_SERVER_URL + value: 'http://{{ include "distribution.fullname" . }}:{{ .Values.distribution.internalPort }}' + volumeMounts: + - name: distributor-data + mountPath: {{ .Values.distributor.persistence.mountPath | quote }} + resources: +{{ toYaml .Values.distributor.resources | indent 10 }} + volumes: + {{- if .Values.distributor.token }} + - name: distributor-token + configMap: + name: {{ template "distributor.fullname" . }}-token + {{- end }} + - name: distributor-data + {{- if .Values.distributor.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ if .Values.distributor.persistence.existingClaim }}{{ .Values.distributor.persistence.existingClaim }}{{- else }}{{ template "distributor.fullname" . }}{{- end }} + {{- else }} + emptyDir: {} + {{- end -}} diff --git a/incubator/distribution/templates/distributor-pvc.yaml b/incubator/distribution/templates/distributor-pvc.yaml new file mode 100644 index 0000000000..e51f814c9d --- /dev/null +++ b/incubator/distribution/templates/distributor-pvc.yaml @@ -0,0 +1,24 @@ +{{- if and .Values.distributor.persistence.enabled (not .Values.distributor.persistence.existingClaim) }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ template "distributor.fullname" . }} + labels: + app: {{ template "distribution.name" . }} + chart: {{ template "distribution.chart" . }} + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + accessModes: + - {{ .Values.distributor.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.distributor.persistence.size }} +{{- if .Values.distributor.persistence.storageClass }} +{{- if (eq "-" .Values.distributor.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.distributor.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end }} diff --git a/incubator/distribution/templates/distributor-token.yaml b/incubator/distribution/templates/distributor-token.yaml new file mode 100644 index 0000000000..f25843eadf --- /dev/null +++ b/incubator/distribution/templates/distributor-token.yaml @@ -0,0 +1,14 @@ +{{- if .Values.distributor.token }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "distributor.fullname" . }}-token + labels: + app: {{ template "distribution.name" . }} + chart: {{ template "distribution.chart" . }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +data: + token: | + {{ .Values.distributor.token }} +{{- end }} \ No newline at end of file diff --git a/incubator/distribution/templates/mongo-connection-secret.yaml b/incubator/distribution/templates/mongo-connection-secret.yaml new file mode 100644 index 0000000000..a5c1588d82 --- /dev/null +++ b/incubator/distribution/templates/mongo-connection-secret.yaml @@ -0,0 +1,15 @@ +{{- if .Values.mongodb.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "distribution.fullname" . }}-mongo-connection + labels: + app: {{ template "distribution.name" . }} + chart: {{ template "distribution.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +type: Opaque +data: + mongo_connectionString: {{ template "mongodb.url" . }} + audit_mongo_connectionString: {{ template "mongodb.audit.url" . }} +{{- end }} \ No newline at end of file diff --git a/incubator/distribution/templates/redis-connection-secret.yaml b/incubator/distribution/templates/redis-connection-secret.yaml new file mode 100644 index 0000000000..4d4933c145 --- /dev/null +++ b/incubator/distribution/templates/redis-connection-secret.yaml @@ -0,0 +1,14 @@ +{{- if .Values.redis.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "distribution.fullname" . }}-redis-connection + labels: + app: {{ template "distribution.name" . }} + chart: {{ template "distribution.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +type: Opaque +data: + redis_connectionString: {{ template "redis.url" . }} +{{- end }} \ No newline at end of file diff --git a/incubator/distribution/values.yaml b/incubator/distribution/values.yaml new file mode 100644 index 0000000000..f3a05842e6 --- /dev/null +++ b/incubator/distribution/values.yaml @@ -0,0 +1,149 @@ +# Default values for distribution. +# This is a YAML-formatted file. +# Beware when changing values here. You should know what you are doing! +# Access the values with {{ .Values.key.subkey }} + +# Common +initContainerImage: "alpine:3.6" + +# For supporting pulling from private registries +imagePullSecrets: + +# Sub charts +## Configuration values for the mongodb dependency +## ref: https://github.com/kubernetes/charts/blob/master/stable/mongodb/README.md +## +mongodb: + enabled: true + image: + tag: 3.6.3 + pullPolicy: IfNotPresent + persistence: + enabled: true + size: 10Gi + resources: {} + # requests: + # memory: "2Gi" + # cpu: "100m" + # limits: + # memory: "2Gi" + # cpu: "250m" + ## Make sure the --wiredTigerCacheSizeGB is no more than half the memory limit! + ## This is critical to protect against OOMKill by Kubernetes! + mongodbExtraFlags: + - "--wiredTigerCacheSizeGB=1" + mongodbRootPassword: + mongodbUsername: distribution + mongodbPassword: + mongodbDatabase: bintray + livenessProbe: + initialDelaySeconds: 40 + readinessProbe: + initialDelaySeconds: 30 + +## Configuration values for the redis dependency +## ref: https://github.com/kubernetes/charts/blob/master/stable/redis/README.md +## +redis: + enabled: true + redisPassword: + persistence: + enabled: true + size: 10Gi + master: + port: 6379 + resources: {} + # requests: + # memory: "1Gi" + # cpu: "100m" + # limits: + # memory: "2Gi" + # cpu: "250m" + +distribution: + replicaCount: 1 + name: distribution + image: + repository: "docker.bintray.io/jfrog/distribution-distribution" + version: 1.0.0 + imagePullPolicy: IfNotPresent + internalPort: 8080 + externalPort: 80 + env: + artifactoryUrl: + btServerUrl: + artifactoryCi1Url: + artifactoryEdge1Url: + artifactoryEdge2Url: + artifactoryEdge3Url: + service: + type: LoadBalancer + resources: {} + # requests: + # memory: "2Gi" + # cpu: "500m" + # limits: + # memory: "4Gi" + # cpu: "2" + ## Control Java options (JAVA_OPTIONS) + ## IMPORTANT: keep javaOpts.xmx no higher than resources.limits.memory + javaOpts: + xms: + xmx: + persistence: + enabled: true + ## A manually managed Persistent Volume and Claim + ## Requires persistence.enabled: true + ## If defined, PVC must be created manually before volume will be bound + # existingClaim: + + accessMode: ReadWriteOnce + mountPath: "/var/opt/jfrog/distribution" + size: 50Gi + ## artifactory data Persistent Volume Storage Class + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + # storageClass: "-" + +distributor: + replicaCount: 1 + name: distributor + image: + repository: "docker.bintray.io/jfrog/distribution-distributor" + version: 1.0.0 + imagePullPolicy: IfNotPresent + token: + resources: {} + # requests: + # memory: "2Gi" + # cpu: "500m" + # limits: + # memory: "4Gi" + # cpu: "2" + ## Control Java options (JAVA_OPTIONS) + ## IMPORTANT: keep javaOpts.xmx no higher than resources.limits.memory + javaOpts: + xms: + xmx: + persistence: + enabled: true + ## A manually managed Persistent Volume and Claim + ## Requires persistence.enabled: true + ## If defined, PVC must be created manually before volume will be bound + # existingClaim: + + accessMode: ReadWriteOnce + mountPath: "/var/opt/jfrog/distributor" + size: 50Gi + ## artifactory data Persistent Volume Storage Class + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + # storageClass: "-"