diff --git a/codefresh.yml b/codefresh.yml index d6ca58c3d..ee0957884 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -1,67 +1,29 @@ version: '1.0' steps: - build_step: - title: Build + BuildingDockerImage: + title: Building Docker Image type: build + image_name: verchol/demochat + #working_directory: ./service1/ dockerfile: Dockerfile - image_name: demochat - tag: '${{CF_BRANCH}}' + tag: '${{CF_BRANCH_TAG_NORMALIZED}}' -# unit_tests: -# title: Unit Tests -# image: ${{build_step}} -# fail_fast: false -# working-directory : /usr/src/app -# commands: -# - npm test - - unit_test: - type: composition - working_directory: '${{main_clone}}' - composition: - version: '2' - services: - mongo: - image: 'mongo:latest' - ports: - - 27017 - composition_candidates: - test: - image: '${{build_step}}' - command: npm test - push_to_registry: - title: Push To Registry + push: type: push - candidate: ${{build_step}} - tag: ${{CF_BRANCH}} - - deploy_to_ecs: - title: Deploy Container to ECS - image: codefresh/cf-deploy-ecs - commands: - - >- - cfecs-update --image-name containers101/demochat --image-tag - ${{CF_BRANCH}} eu-west-1 demochat-production demochat-service - environment: - - 'AWS_ACCESS_KEY_ID=${{AWS_ACCESS_KEY_ID}}' - - 'AWS_SECRET_ACCESS_KEY=${{AWS_SECRET_ACCESS_KEY}}' - when: - condition: - all: - deploy_to_ecs: '"${{DEPLOY_ECS}}" == "true"' + title: push + description: Free text description + candidate: ${{BuildingDockerImage}} + image_name: verchol/demochat + tag: v1.0 + registry: dockerhub - deploy_to_kubernetes: - image: codefresh/cf-deploy-kubernetes - tag: latest - working_directory: ${{main_clone}} + integration-tests: + title : helm step + image: verchol/helmclient:v2.6.1 commands: - - /cf-deploy-kubernetes deployment.yml - environment: - - KUBERNETES_USER=${{KUBERNETES_USER}} - - KUBERNETES_PASSWORD=${{KUBERNETES_PASSWORD}} - - KUBERNETES_SERVER=${{KUBERNETES_SERVER}} - - DOCKER_IMAGE_TAG=${{CF_BRANCH}} - when: - condition: - all: - deploy_to_kubernetes: '"${{DEPLOY_KUBERNETES}}" == "true"' + - kubectl config use-context gke_kuberentes_us-central1-a_demo-chat + - helm ls + - helm upgrade --install --namespace qa1 --set test.tries=40 --set appversion=14 --set tag=v1.0 --set=commit.sha={{CF_REVISION} --set=commit.branch=${{CF_BRANCH}} integrations${{CF_REVISION}} ./deploy/demochatChart + - sleep 10 + - helm test integrations${{CF_REVISION}} || true + - kubectl delete pods/integrations${{CF_REVISION}}-e2e-test -nqa1 diff --git a/deploy/.helmignore b/deploy/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/deploy/.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/deploy/Chart.yaml b/deploy/Chart.yaml new file mode 100644 index 000000000..ce7e5b376 --- /dev/null +++ b/deploy/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: demochat +name: demochat +version: 0.0.1 diff --git a/deploy/all.yaml b/deploy/all.yaml deleted file mode 100644 index bf9a1f1ae..000000000 --- a/deploy/all.yaml +++ /dev/null @@ -1,110 +0,0 @@ - -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - name: demo-chat - labels: - deploy: test1 - service: demo-chat - app: demo-chat -spec: - replicas: 2 - template: - metadata: - labels: - deploy: test1 - service: demo-chat - spec: - imagePullSecrets: - - name: cfcr - containers: - - image: containers101/demochat:master - name: app - imagePullPolicy: Always - ports: - - containerPort: 5000 - protocol: TCP ---- - apiVersion: extensions/v1beta1 - kind: Ingress - metadata: - labels: - deploy: test1 - name: demochat-ingress - spec: - backend: - serviceName: demochat-board - servicePort: 80 ---- - apiVersion: v1 - kind: Service - metadata: - labels: - deploy: test1 - name: demochat-master - spec: - type: NodePort - selector: - app: demo-chat - ports: - - name: "http" - port: 80 - protocol: TCP - targetPort: 5000 - selector: - service: demochat-board ---- -apiVersion: v1 -kind: Service -metadata: - labels: - app: mongo - name: mongo -spec: - type: NodePort - ports: - - name: "http" - port: 27017 - protocol: TCP - targetPort: 27017 - selector: - service: mongo ---- -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: mongo -spec: - backend: - serviceName: mongo - servicePort: 27017 ---- -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - annotations: - io.codefresh.owner: codefresh - name: mongo -spec: - replicas: 1 - template: - metadata: - labels: - service: mongo - spec: - containers: - - args: - - mongod - - --smallfiles - image: mongo:latest - name: mongo - ports: - - containerPort: 27017 - protocol: TCP - volumeMounts: - - mountPath: /data/db - name: mongo-data - restartPolicy: Always - volumes: - - name: mongo-data - emptyDir: {} diff --git a/deploy/charts/demoservice2/.helmignore b/deploy/charts/demoservice2/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/deploy/charts/demoservice2/.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/deploy/charts/demoservice2/Chart.yaml b/deploy/charts/demoservice2/Chart.yaml new file mode 100644 index 000000000..d19170c79 --- /dev/null +++ b/deploy/charts/demoservice2/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: demoservice2 +version: 0.1.1 diff --git a/deploy/charts/demoservice2/templates/NOTES.txt b/deploy/charts/demoservice2/templates/NOTES.txt new file mode 100644 index 000000000..ccfecb7ea --- /dev/null +++ b/deploy/charts/demoservice2/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http://{{ . }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "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.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.externalPort }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }} +{{- end }} diff --git a/deploy/charts/demoservice2/templates/_helpers.tpl b/deploy/charts/demoservice2/templates/_helpers.tpl new file mode 100644 index 000000000..f0d83d2ed --- /dev/null +++ b/deploy/charts/demoservice2/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/deploy/charts/demoservice2/templates/configmap.yaml b/deploy/charts/demoservice2/templates/configmap.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/deploy/charts/demoservice2/templates/deployment.yaml b/deploy/charts/demoservice2/templates/deployment.yaml new file mode 100644 index 000000000..ac14a0bf8 --- /dev/null +++ b/deploy/charts/demoservice2/templates/deployment.yaml @@ -0,0 +1,45 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "name" . }} + appversion: "{{.Values.appversion}}" + release: {{ .Release.Name }} + test : "works" + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + env: + - name: appversion + value : "2" + # - name: service + + # value : "{{.Values.service.name}}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.internalPort }} + livenessProbe: + httpGet: + path: / + port: {{ .Values.service.internalPort }} + readinessProbe: + httpGet: + path: /mongo + port: {{ .Values.service.internalPort }} + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/deploy/charts/demoservice2/templates/ingress.yaml b/deploy/charts/demoservice2/templates/ingress.yaml new file mode 100644 index 000000000..b09eb9075 --- /dev/null +++ b/deploy/charts/demoservice2/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/deploy/charts/demoservice2/templates/service.yaml b/deploy/charts/demoservice2/templates/service.yaml new file mode 100644 index 000000000..f311d10a0 --- /dev/null +++ b/deploy/charts/demoservice2/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + protocol: TCP + name: {{ .Values.service.name }} + selector: + app: {{ template "name" . }} + release: {{ .Release.Name }} diff --git a/deploy/charts/demoservice2/templates/test/sanity.yaml b/deploy/charts/demoservice2/templates/test/sanity.yaml new file mode 100644 index 000000000..896bde12b --- /dev/null +++ b/deploy/charts/demoservice2/templates/test/sanity.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "release-sanity-test" + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: release-sanity-test + image: alpine:latest + env: + - name: TEST + value: works + command: ["wget"] + args: ["{{ template "fullname" . }}"] + restartPolicy: Never diff --git a/deploy/charts/demoservice2/values.yaml b/deploy/charts/demoservice2/values.yaml new file mode 100644 index 000000000..ceffb3288 --- /dev/null +++ b/deploy/charts/demoservice2/values.yaml @@ -0,0 +1,38 @@ +# Default values for demoservice2. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +appversion: "1" +image: + repository: verchol/demo-service1 + tag: v5 + pullPolicy: IfNotPresent +service: + name: demo-service2 + type: LoadBalancer + externalPort: 80 + internalPort: 3000 +ingress: + enabled: true + # Used to create an Ingress record. + hosts: + - demoservice2 + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + tls: + # Secrets must be manually created in the namespace. + # - secretName: chart-example-tls + # hosts: + # - chart-example.local +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi diff --git a/deploy/charts/mongodb/.helmignore b/deploy/charts/mongodb/.helmignore new file mode 100644 index 000000000..6b8710a71 --- /dev/null +++ b/deploy/charts/mongodb/.helmignore @@ -0,0 +1 @@ +.git diff --git a/deploy/charts/mongodb/Chart.yaml b/deploy/charts/mongodb/Chart.yaml new file mode 100644 index 000000000..c0d9e96ab --- /dev/null +++ b/deploy/charts/mongodb/Chart.yaml @@ -0,0 +1,16 @@ +name: mongodb +version: 0.4.18 +appVersion: 3.4.10 +description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications. +keywords: +- mongodb +- database +- nosql +home: https://mongodb.org +icon: https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png +sources: +- https://github.com/bitnami/bitnami-docker-mongodb +maintainers: +- name: Bitnami + email: containers@bitnami.com +engine: gotpl diff --git a/deploy/charts/mongodb/README.md b/deploy/charts/mongodb/README.md new file mode 100644 index 000000000..bac5168a3 --- /dev/null +++ b/deploy/charts/mongodb/README.md @@ -0,0 +1,84 @@ +# MongoDB + +[MongoDB](https://www.mongodb.com/) is a cross-platform document-oriented database. Classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas, making the integration of data in certain types of applications easier and faster. + +## TL;DR; + +```bash +$ helm install stable/mongodb +``` + +## Introduction + +This chart bootstraps a [MongoDB](https://github.com/bitnami/bitnami-docker-mongodb) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes 1.4+ with Beta APIs enabled +- PV provisioner support in the underlying infrastructure + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +$ helm install --name my-release stable/mongodb +``` + +The command deploys MongoDB on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```bash +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following tables lists the configurable parameters of the MongoDB chart and their default values. + +| Parameter | Description | Default | +|----------------------------|-------------------------------------|----------------------------------------------------------| +| `image` | MongoDB image | `bitnami/mongodb:{VERSION}` | +| `imagePullPolicy` | Image pull policy | `Always` if `imageTag` is `latest`, else `IfNotPresent`. | +| `mongodbRootPassword` | MongoDB admin password | `nil` | +| `mongodbUsername` | MongoDB custom user | `nil` | +| `mongodbPassword` | MongoDB custom user password | `nil` | +| `mongodbDatabase` | Database to create | `nil` | +| `serviceType` | Kubernetes Service type | `ClusterIP` | +| `persistence.enabled` | Use a PVC to persist data | `true` | +| `persistence.storageClass` | Storage class of backing PVC | `nil` (uses alpha storage class annotation) | +| `persistence.accessMode` | Use volume as ReadOnly or ReadWrite | `ReadWriteOnce` | +| `persistence.size` | Size of data volume | `8Gi` | + +The above parameters map to the env variables defined in [bitnami/mongodb](http://github.com/bitnami/bitnami-docker-mongodb). For more information please refer to the [bitnami/mongodb](http://github.com/bitnami/bitnami-docker-mongodb) image documentation. + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```bash +$ helm install --name my-release \ + --set mongodbRootPassword=secretpassword,mongodbUsername=my-user,mongodbPassword=my-password,mongodbDatabase=my-database \ + stable/mongodb +``` + +The above command sets the MongoDB `root` account password to `secretpassword`. Additionally it creates a standard database user named `my-user`, with the password `my-password`, who has access to a database named `my-database`. + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```bash +$ helm install --name my-release -f values.yaml stable/mongodb +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) + +## Persistence + +The [Bitnami MongoDB](https://github.com/bitnami/bitnami-docker-mongodb) image stores the MongoDB data and configurations at the `/bitnami/mongodb` path of the container. + +The chart mounts a [Persistent Volume](http://kubernetes.io/docs/user-guide/persistent-volumes/) volume at this location. The volume is created using dynamic volume provisioning. diff --git a/deploy/charts/mongodb/templates/NOTES.txt b/deploy/charts/mongodb/templates/NOTES.txt new file mode 100644 index 000000000..24c5d200b --- /dev/null +++ b/deploy/charts/mongodb/templates/NOTES.txt @@ -0,0 +1,7 @@ +MongoDB can be accessed via port 27017 on the following DNS name from within your cluster: +{{ template "mongodb.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local + +To connect to your database run the following command: + + kubectl run {{ template "mongodb.fullname" . }}-client --rm --tty -i --image bitnami/mongodb --command -- mongo --host {{ template "mongodb.fullname" . }} {{- if .Values.mongodbRootPassword }} -p {{ .Values.mongodbRootPassword }}{{- end -}} + diff --git a/deploy/charts/mongodb/templates/_helpers.tpl b/deploy/charts/mongodb/templates/_helpers.tpl new file mode 100644 index 000000000..ad4a3f5ef --- /dev/null +++ b/deploy/charts/mongodb/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "mongodb.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "mongodb.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/deploy/charts/mongodb/templates/deployment.yaml b/deploy/charts/mongodb/templates/deployment.yaml new file mode 100644 index 000000000..55901ecd7 --- /dev/null +++ b/deploy/charts/mongodb/templates/deployment.yaml @@ -0,0 +1,66 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "mongodb.fullname" . }} + labels: + app: {{ template "mongodb.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + template: + metadata: + labels: + app: {{ template "mongodb.fullname" . }} + spec: + containers: + - name: {{ template "mongodb.fullname" . }} + image: "{{ .Values.image }}" + imagePullPolicy: {{ default "" .Values.imagePullPolicy | quote }} + env: + - name: MONGODB_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "mongodb.fullname" . }} + key: mongodb-root-password + - name: MONGODB_USERNAME + value: {{ default "" .Values.mongodbUsername | quote }} + - name: MONGODB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "mongodb.fullname" . }} + key: mongodb-password + - name: MONGODB_DATABASE + value: {{ default "" .Values.mongodbDatabase | quote }} + ports: + - name: mongodb + containerPort: 27017 + livenessProbe: + exec: + command: + - mongo + - --eval + - "db.adminCommand('ping')" + initialDelaySeconds: 30 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - mongo + - --eval + - "db.adminCommand('ping')" + initialDelaySeconds: 5 + timeoutSeconds: 1 + volumeMounts: + - name: data + mountPath: /bitnami/mongodb + resources: +{{ toYaml .Values.resources | indent 10 }} + volumes: + - name: data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ template "mongodb.fullname" . }} + {{- else }} + emptyDir: {} + {{- end -}} diff --git a/deploy/charts/mongodb/templates/pvc.yaml b/deploy/charts/mongodb/templates/pvc.yaml new file mode 100644 index 000000000..f53516f90 --- /dev/null +++ b/deploy/charts/mongodb/templates/pvc.yaml @@ -0,0 +1,19 @@ +{{- if .Values.persistence.enabled }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "mongodb.fullname" . }} +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end }} diff --git a/deploy/charts/mongodb/templates/secrets.yaml b/deploy/charts/mongodb/templates/secrets.yaml new file mode 100644 index 000000000..d95e7a451 --- /dev/null +++ b/deploy/charts/mongodb/templates/secrets.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "mongodb.fullname" . }} + labels: + app: {{ template "mongodb.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +type: Opaque +data: + mongodb-root-password: {{ default "" .Values.mongodbRootPassword | b64enc | quote }} + mongodb-password: {{ default "" .Values.mongodbPassword | b64enc | quote }} diff --git a/deploy/charts/mongodb/templates/svc.yaml b/deploy/charts/mongodb/templates/svc.yaml new file mode 100644 index 000000000..6c58b54c5 --- /dev/null +++ b/deploy/charts/mongodb/templates/svc.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "mongodb.fullname" . }} + labels: + app: {{ template "mongodb.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + type: {{ .Values.serviceType }} + ports: + - name: mongodb + port: 27017 + targetPort: mongodb + selector: + app: {{ template "mongodb.fullname" . }} diff --git a/deploy/charts/mongodb/values.yaml b/deploy/charts/mongodb/values.yaml new file mode 100644 index 000000000..294a3efce --- /dev/null +++ b/deploy/charts/mongodb/values.yaml @@ -0,0 +1,49 @@ +## Bitnami MongoDB image version +## ref: https://hub.docker.com/r/bitnami/mongodb/tags/ +## +image: bitnami/mongodb:3.4.10-r0 + +## Specify a imagePullPolicy +## 'Always' if imageTag is 'latest', else set to 'IfNotPresent' +## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images +## +# imagePullPolicy: + +## MongoDB admin password +## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#setting-the-root-password-on-first-run +## +# mongodbRootPassword: + +## MongoDB custom user and database +## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#creating-a-user-and-database-on-first-run +## +# mongodbUsername: +# mongodbPassword: +# mongodbDatabase: + +## Kubernetes service type +serviceType: ClusterIP + +## Enable persistence using Persistent Volume Claims +## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ +## +persistence: + enabled: true + ## mongodb 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: "-" + accessMode: ReadWriteOnce + size: 8Gi + +## Configure resource requests and limits +## ref: http://kubernetes.io/docs/user-guide/compute-resources/ +## +resources: + requests: + memory: 256Mi + cpu: 100m diff --git a/deploy/demochatChart/.helmignore b/deploy/demochatChart/.helmignore new file mode 100644 index 000000000..f0c131944 --- /dev/null +++ b/deploy/demochatChart/.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/deploy/demochatChart/Chart.yaml b/deploy/demochatChart/Chart.yaml new file mode 100644 index 000000000..ce7e5b376 --- /dev/null +++ b/deploy/demochatChart/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: demochat +name: demochat +version: 0.0.1 diff --git a/deploy/demochatChart/charts/mongodb/.helmignore b/deploy/demochatChart/charts/mongodb/.helmignore new file mode 100644 index 000000000..6b8710a71 --- /dev/null +++ b/deploy/demochatChart/charts/mongodb/.helmignore @@ -0,0 +1 @@ +.git diff --git a/deploy/demochatChart/charts/mongodb/Chart.yaml b/deploy/demochatChart/charts/mongodb/Chart.yaml new file mode 100644 index 000000000..c0d9e96ab --- /dev/null +++ b/deploy/demochatChart/charts/mongodb/Chart.yaml @@ -0,0 +1,16 @@ +name: mongodb +version: 0.4.18 +appVersion: 3.4.10 +description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications. +keywords: +- mongodb +- database +- nosql +home: https://mongodb.org +icon: https://bitnami.com/assets/stacks/mongodb/img/mongodb-stack-220x234.png +sources: +- https://github.com/bitnami/bitnami-docker-mongodb +maintainers: +- name: Bitnami + email: containers@bitnami.com +engine: gotpl diff --git a/deploy/demochatChart/charts/mongodb/README.md b/deploy/demochatChart/charts/mongodb/README.md new file mode 100644 index 000000000..bac5168a3 --- /dev/null +++ b/deploy/demochatChart/charts/mongodb/README.md @@ -0,0 +1,84 @@ +# MongoDB + +[MongoDB](https://www.mongodb.com/) is a cross-platform document-oriented database. Classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas, making the integration of data in certain types of applications easier and faster. + +## TL;DR; + +```bash +$ helm install stable/mongodb +``` + +## Introduction + +This chart bootstraps a [MongoDB](https://github.com/bitnami/bitnami-docker-mongodb) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes 1.4+ with Beta APIs enabled +- PV provisioner support in the underlying infrastructure + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +$ helm install --name my-release stable/mongodb +``` + +The command deploys MongoDB on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```bash +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following tables lists the configurable parameters of the MongoDB chart and their default values. + +| Parameter | Description | Default | +|----------------------------|-------------------------------------|----------------------------------------------------------| +| `image` | MongoDB image | `bitnami/mongodb:{VERSION}` | +| `imagePullPolicy` | Image pull policy | `Always` if `imageTag` is `latest`, else `IfNotPresent`. | +| `mongodbRootPassword` | MongoDB admin password | `nil` | +| `mongodbUsername` | MongoDB custom user | `nil` | +| `mongodbPassword` | MongoDB custom user password | `nil` | +| `mongodbDatabase` | Database to create | `nil` | +| `serviceType` | Kubernetes Service type | `ClusterIP` | +| `persistence.enabled` | Use a PVC to persist data | `true` | +| `persistence.storageClass` | Storage class of backing PVC | `nil` (uses alpha storage class annotation) | +| `persistence.accessMode` | Use volume as ReadOnly or ReadWrite | `ReadWriteOnce` | +| `persistence.size` | Size of data volume | `8Gi` | + +The above parameters map to the env variables defined in [bitnami/mongodb](http://github.com/bitnami/bitnami-docker-mongodb). For more information please refer to the [bitnami/mongodb](http://github.com/bitnami/bitnami-docker-mongodb) image documentation. + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```bash +$ helm install --name my-release \ + --set mongodbRootPassword=secretpassword,mongodbUsername=my-user,mongodbPassword=my-password,mongodbDatabase=my-database \ + stable/mongodb +``` + +The above command sets the MongoDB `root` account password to `secretpassword`. Additionally it creates a standard database user named `my-user`, with the password `my-password`, who has access to a database named `my-database`. + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```bash +$ helm install --name my-release -f values.yaml stable/mongodb +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) + +## Persistence + +The [Bitnami MongoDB](https://github.com/bitnami/bitnami-docker-mongodb) image stores the MongoDB data and configurations at the `/bitnami/mongodb` path of the container. + +The chart mounts a [Persistent Volume](http://kubernetes.io/docs/user-guide/persistent-volumes/) volume at this location. The volume is created using dynamic volume provisioning. diff --git a/deploy/demochatChart/charts/mongodb/templates/NOTES.txt b/deploy/demochatChart/charts/mongodb/templates/NOTES.txt new file mode 100644 index 000000000..24c5d200b --- /dev/null +++ b/deploy/demochatChart/charts/mongodb/templates/NOTES.txt @@ -0,0 +1,7 @@ +MongoDB can be accessed via port 27017 on the following DNS name from within your cluster: +{{ template "mongodb.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local + +To connect to your database run the following command: + + kubectl run {{ template "mongodb.fullname" . }}-client --rm --tty -i --image bitnami/mongodb --command -- mongo --host {{ template "mongodb.fullname" . }} {{- if .Values.mongodbRootPassword }} -p {{ .Values.mongodbRootPassword }}{{- end -}} + diff --git a/deploy/demochatChart/charts/mongodb/templates/_helpers.tpl b/deploy/demochatChart/charts/mongodb/templates/_helpers.tpl new file mode 100644 index 000000000..ad4a3f5ef --- /dev/null +++ b/deploy/demochatChart/charts/mongodb/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "mongodb.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "mongodb.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/deploy/demochatChart/charts/mongodb/templates/deployment.yaml b/deploy/demochatChart/charts/mongodb/templates/deployment.yaml new file mode 100644 index 000000000..55901ecd7 --- /dev/null +++ b/deploy/demochatChart/charts/mongodb/templates/deployment.yaml @@ -0,0 +1,66 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "mongodb.fullname" . }} + labels: + app: {{ template "mongodb.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + template: + metadata: + labels: + app: {{ template "mongodb.fullname" . }} + spec: + containers: + - name: {{ template "mongodb.fullname" . }} + image: "{{ .Values.image }}" + imagePullPolicy: {{ default "" .Values.imagePullPolicy | quote }} + env: + - name: MONGODB_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "mongodb.fullname" . }} + key: mongodb-root-password + - name: MONGODB_USERNAME + value: {{ default "" .Values.mongodbUsername | quote }} + - name: MONGODB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "mongodb.fullname" . }} + key: mongodb-password + - name: MONGODB_DATABASE + value: {{ default "" .Values.mongodbDatabase | quote }} + ports: + - name: mongodb + containerPort: 27017 + livenessProbe: + exec: + command: + - mongo + - --eval + - "db.adminCommand('ping')" + initialDelaySeconds: 30 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - mongo + - --eval + - "db.adminCommand('ping')" + initialDelaySeconds: 5 + timeoutSeconds: 1 + volumeMounts: + - name: data + mountPath: /bitnami/mongodb + resources: +{{ toYaml .Values.resources | indent 10 }} + volumes: + - name: data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ template "mongodb.fullname" . }} + {{- else }} + emptyDir: {} + {{- end -}} diff --git a/deploy/demochatChart/charts/mongodb/templates/pvc.yaml b/deploy/demochatChart/charts/mongodb/templates/pvc.yaml new file mode 100644 index 000000000..f53516f90 --- /dev/null +++ b/deploy/demochatChart/charts/mongodb/templates/pvc.yaml @@ -0,0 +1,19 @@ +{{- if .Values.persistence.enabled }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "mongodb.fullname" . }} +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end }} diff --git a/deploy/demochatChart/charts/mongodb/templates/secrets.yaml b/deploy/demochatChart/charts/mongodb/templates/secrets.yaml new file mode 100644 index 000000000..d95e7a451 --- /dev/null +++ b/deploy/demochatChart/charts/mongodb/templates/secrets.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "mongodb.fullname" . }} + labels: + app: {{ template "mongodb.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +type: Opaque +data: + mongodb-root-password: {{ default "" .Values.mongodbRootPassword | b64enc | quote }} + mongodb-password: {{ default "" .Values.mongodbPassword | b64enc | quote }} diff --git a/deploy/demochatChart/charts/mongodb/templates/svc.yaml b/deploy/demochatChart/charts/mongodb/templates/svc.yaml new file mode 100644 index 000000000..6c58b54c5 --- /dev/null +++ b/deploy/demochatChart/charts/mongodb/templates/svc.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "mongodb.fullname" . }} + labels: + app: {{ template "mongodb.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + type: {{ .Values.serviceType }} + ports: + - name: mongodb + port: 27017 + targetPort: mongodb + selector: + app: {{ template "mongodb.fullname" . }} diff --git a/deploy/demochatChart/charts/mongodb/values.yaml b/deploy/demochatChart/charts/mongodb/values.yaml new file mode 100644 index 000000000..294a3efce --- /dev/null +++ b/deploy/demochatChart/charts/mongodb/values.yaml @@ -0,0 +1,49 @@ +## Bitnami MongoDB image version +## ref: https://hub.docker.com/r/bitnami/mongodb/tags/ +## +image: bitnami/mongodb:3.4.10-r0 + +## Specify a imagePullPolicy +## 'Always' if imageTag is 'latest', else set to 'IfNotPresent' +## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images +## +# imagePullPolicy: + +## MongoDB admin password +## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#setting-the-root-password-on-first-run +## +# mongodbRootPassword: + +## MongoDB custom user and database +## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#creating-a-user-and-database-on-first-run +## +# mongodbUsername: +# mongodbPassword: +# mongodbDatabase: + +## Kubernetes service type +serviceType: ClusterIP + +## Enable persistence using Persistent Volume Claims +## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ +## +persistence: + enabled: true + ## mongodb 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: "-" + accessMode: ReadWriteOnce + size: 8Gi + +## Configure resource requests and limits +## ref: http://kubernetes.io/docs/user-guide/compute-resources/ +## +resources: + requests: + memory: 256Mi + cpu: 100m diff --git a/deploy/demochatChart/requirements.yaml b/deploy/demochatChart/requirements.yaml new file mode 100644 index 000000000..32855b0cd --- /dev/null +++ b/deploy/demochatChart/requirements.yaml @@ -0,0 +1,4 @@ +dependencies: + - name: mongodb + version: 0.4.18 + repository: mongodb diff --git a/deploy/demochatChart/templates/NOTES.txt b/deploy/demochatChart/templates/NOTES.txt new file mode 100644 index 000000000..ccfecb7ea --- /dev/null +++ b/deploy/demochatChart/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http://{{ . }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "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.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.externalPort }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }} +{{- end }} diff --git a/deploy/demochatChart/templates/_helpers.tpl b/deploy/demochatChart/templates/_helpers.tpl new file mode 100644 index 000000000..05ca5cee4 --- /dev/null +++ b/deploy/demochatChart/templates/_helpers.tpl @@ -0,0 +1,21 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{/* KUBECON_DEMOCHAT_SERVICE_HOST */}} +{{- define "demochat" -}} +{{- $service :=default .Release.Name -}} +{{- printf "%s_DEMOCHAT_SERVICE_HOST" .Release.Name| upper -}} +{{- end -}} +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/deploy/demochatChart/templates/configMap.yaml b/deploy/demochatChart/templates/configMap.yaml new file mode 100644 index 000000000..b1ee53f35 --- /dev/null +++ b/deploy/demochatChart/templates/configMap.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{.Release.Name }}-config + namespace: default +data: + sha: "{{ .Values.commit.sha }}" + branch: "{{ .Values.commit.branch }}" + repo: "{{ .Values.commit.repo }}" diff --git a/deploy/demochatChart/templates/deployment.yaml b/deploy/demochatChart/templates/deployment.yaml new file mode 100644 index 000000000..3952bd3d5 --- /dev/null +++ b/deploy/demochatChart/templates/deployment.yaml @@ -0,0 +1,38 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + # appversion: "{{.Values.appversion}}" +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "name" . }} + release: {{ .Release.Name }} + # imageinfo : {{.Values.test.key}} + appversion: "{{.Values.appversion}}" + spec: + imagePullSecrets: + - name: {{ .Values.pullsecret.name }} + containers: + - image: {{ .Values.image.name }} + - image: {{.Values.image.repository}}:{{.Values.image.tag}} + name: app + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name : MONGO_HELM + value: {{.Release.Name }}-mongodb + ports: + - containerPort: {{ .Values.service.internalPort }} + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/deploy/demochatChart/templates/ingress.yaml b/deploy/demochatChart/templates/ingress.yaml new file mode 100644 index 000000000..b09eb9075 --- /dev/null +++ b/deploy/demochatChart/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/deploy/demochatChart/templates/secrets.yaml b/deploy/demochatChart/templates/secrets.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/deploy/demochatChart/templates/service.yaml b/deploy/demochatChart/templates/service.yaml new file mode 100644 index 000000000..646cda37e --- /dev/null +++ b/deploy/demochatChart/templates/service.yaml @@ -0,0 +1,22 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + sha: {{ .Values.commit.sha }} + branch: "{{ .Values.commit.branch }}" + repo: "{{ .Values.commit.repo }}" +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + protocol: TCP + name: {{ .Values.service.name }} + selector: + app: {{ template "name" . }} + release: {{ .Release.Name }} diff --git a/deploy/demochatChart/templates/test/e2e.spec.yaml b/deploy/demochatChart/templates/test/e2e.spec.yaml new file mode 100644 index 000000000..294e5e344 --- /dev/null +++ b/deploy/demochatChart/templates/test/e2e.spec.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ .Release.Name }}-e2e-test" + annotations: + "helm.sh/hook": test-success +spec: + imagePullSecrets: + - name: {{ .Values.pullsecret.name }} + containers: + - name: {{ .Release.Name }}-e2e-test + image: {{ .Values.test.image}} + command: ["/bin/sh"] + args: ["-c" , 'wget --tries {{.Values.test.tries}} $(echo http://${{ template "demochat" . }}/login) '] + #["bin/sh"] + #args : ["-c", "sleep 10000"] + # ["http://{{ .Release.Name }}-demochat/login"] + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: serviceName + value: {{ .Values.service.name }} + + #W["sh", "-c", "curl $serviceNAme:80&&echo workded"] + restartPolicy: Never diff --git a/deploy/demochatChart/values.yaml b/deploy/demochatChart/values.yaml new file mode 100644 index 000000000..7e35df344 --- /dev/null +++ b/deploy/demochatChart/values.yaml @@ -0,0 +1,58 @@ +# Default values for demoservice1. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +appversion: 9 +build : "1" +test: + key: "value2" +pullsecret: + name: codefresh-generated-r.cfcr.io-cfcr-default +image: + repository: jennyps/demochat + name: jennyps/demochat:kubecon + tag: v8 + pullPolicy: Always +test: + image: r.cfcr.io/jennyps/demochat:kubecon + repository: containers101/demochat + tag: master + pullPolicy: IfNotPresent +test: + image: mwendler/wget + timeout : 5 # number of seconds for reconnect + tries : 40 #number of retries + image: jennyps/demochat:kubecon +service: + name: demochat + type: LoadBalancer + externalPort: 80 + internalPort: 5000 +commit: + sha: "1234" + branch: "master" + repo : "jennyps/demochat" +ingress: + enabled: false + # Used to create an Ingress record. + hosts: + - chart-example.local + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + tls: + # Secrets must be manually created in the namespace. + # - secretName: chart-example-tls + # hosts: + # - chart-example.local +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi diff --git a/deploy/requirements.yaml b/deploy/requirements.yaml new file mode 100644 index 000000000..74b61b104 --- /dev/null +++ b/deploy/requirements.yaml @@ -0,0 +1,6 @@ +dependencies: + - name: mongodb + version: 0.4.18 + repository: mongodb + - name: demoservice2 + version: 0.1.0 diff --git a/deploy/templates/NOTES.txt b/deploy/templates/NOTES.txt new file mode 100644 index 000000000..ccfecb7ea --- /dev/null +++ b/deploy/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http://{{ . }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "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.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.externalPort }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }} +{{- end }} diff --git a/deploy/templates/_helpers.tpl b/deploy/templates/_helpers.tpl new file mode 100644 index 000000000..f0d83d2ed --- /dev/null +++ b/deploy/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/deploy/templates/configMap.yaml b/deploy/templates/configMap.yaml new file mode 100644 index 000000000..4e4c4a965 --- /dev/null +++ b/deploy/templates/configMap.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "name" . }}-config + namespace: default +data: + sha: "{{ .Values.commit.sha }}" + branch: "{{ .Values.commit.branch }}" + repo: "{{ .Values.commit.repo }}" diff --git a/deploy/templates/deployment.yaml b/deploy/templates/deployment.yaml new file mode 100644 index 000000000..9ee903466 --- /dev/null +++ b/deploy/templates/deployment.yaml @@ -0,0 +1,53 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + # appversion: "{{.Values.appversion}}" +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "name" . }} + release: {{ .Release.Name }} + # imageinfo : {{.Values.test.key}} + appversion: "{{.Values.appversion}}" + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{.Values.tag}}" + command: ["/bin/sh", "-c", "ls /etc/foo"] + envFrom : + - configMapRef: + name: {{ template "name" . }}-config + volumeMounts: + - name: foo + mountPath: "/etc/foo" + readOnly: true + volumes: + - name: foo + secret: + secretName: db-user-pass + + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.internalPort }} + livenessProbe: + httpGet: + path: / + port: {{ .Values.service.internalPort }} + readinessProbe: + httpGet: + path: /mongo + port: {{ .Values.service.internalPort }} + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/deploy/templates/ingress.yaml b/deploy/templates/ingress.yaml new file mode 100644 index 000000000..b09eb9075 --- /dev/null +++ b/deploy/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "fullname" . }} + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/deploy/templates/secrets.yaml b/deploy/templates/secrets.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/deploy/templates/service.yaml b/deploy/templates/service.yaml new file mode 100644 index 000000000..522945a16 --- /dev/null +++ b/deploy/templates/service.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fullname" . }} + annotations: + sha: "{{ .Values.commit.sha }}" + branch: "{{ .Values.commit.branch }}" + repo: "{{ .Values.commit.repo }}" + labels: + app: {{ template "name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + protocol: TCP + name: {{ .Values.service.name }} + selector: + app: {{ template "name" . }} + release: {{ .Release.Name }} diff --git a/deploy/templates/test/e2e.spec.yaml b/deploy/templates/test/e2e.spec.yaml new file mode 100644 index 000000000..209b131e3 --- /dev/null +++ b/deploy/templates/test/e2e.spec.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ .Release.Name }}-e2e-test" + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: {{ .Release.Name }}-e2e-test + image: {{ .Values.test.image}} + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: serviceName + value: {{ .Values.service.name }} + command: ["npm", "test"] + #W["sh", "-c", "curl $serviceNAme:80&&echo workded"] + restartPolicy: Never diff --git a/deploy/values.yaml b/deploy/values.yaml new file mode 100644 index 000000000..a8f094fc1 --- /dev/null +++ b/deploy/values.yaml @@ -0,0 +1,47 @@ +# Default values for demoservice1. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +appversion: 9 +build : "1" +test: + key: "value2" +image: + repository: verchol/demo-service1 + tag: v8 + pullPolicy: IfNotPresent +test: + image: verchol/demo-service1:v2 +service: + name: demo-service1 + type: LoadBalancer + externalPort: 80 + internalPort: 3000 + commit: + sha: "1234" + branch: "master" + repo : "verchol/demochat" +ingress: + enabled: false + # Used to create an Ingress record. + hosts: + - chart-example.local + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + tls: + # Secrets must be manually created in the namespace. + # - secretName: chart-example-tls + # hosts: + # - chart-example.local +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi diff --git a/kubecon.yaml b/kubecon.yaml new file mode 100644 index 000000000..1008701b7 --- /dev/null +++ b/kubecon.yaml @@ -0,0 +1,31 @@ +version: '1.0' +steps: + BuildingDockerImage: + title: Building Docker Image + type: build + image_name: demochat + #working_directory: ./service1/ + dockerfile: Dockerfile + tag: '${{CF_BRANCH_TAG_NORMALIZED}}' + + pushToRegistry: + type: push + title: push + description: push to cfcr + candidate: ${{BuildingDockerImage}} + tag: '${{CF_BRANCH_TAG_NORMALIZED}}' + image_name: demochat + registry: cfcr + fail_fast: false + + IntegrationTests: + title : helm step + image: verchol/helmclient:v2.6.1 + commands: + - kubectl config use-context jennys-cluster@codefresh-staging + - if [ $(helm ls | grep integrations${{CF_REVISION}} | awk '{print $8}') == "FAILED" ]; then helm delete --purge integrations${{CF_REVISION}}; fi + - helm upgrade integrations${{CF_REVISION}} deploy/demochatChart --install --namespace ${{NAMESPACE}} --set test.tries=40 --set appversion=14 --set tag=v1.0 --set commit.sha={{CF_REVISION}} --set commit.branch=${{CF_BRANCH}} --reset-values --force --debug + - sleep 10 + - echo "Cleaning previous test pod..."; kubectl delete pods/integrations${{CF_REVISION}}-e2e-test -n${{NAMESPACE}} || true + - echo "Running integration test ..."; helm test integrations${{CF_REVISION}} || true + - echo "Cleaning test pod ..."; kubectl delete pods/integrations${{CF_REVISION}}-e2e-test -n${{NAMESPACE}} diff --git a/templates/login.html b/templates/login.html index b86093c0e..c1f24b24d 100644 --- a/templates/login.html +++ b/templates/login.html @@ -14,7 +14,7 @@ <% block body %>