From 10eeefe34a4e96250e3d402c7bf916cb0c606cd2 Mon Sep 17 00:00:00 2001 From: Gelevb <48049770+Gelevb@users.noreply.github.com> Date: Tue, 21 Jul 2020 09:31:09 +0300 Subject: [PATCH 01/12] Update app.py --- app/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/app.py b/app/app.py index 12cd6ba5..2e03b32f 100644 --- a/app/app.py +++ b/app/app.py @@ -1,5 +1,6 @@ from flask import Flask,render_template import socket +import os app = Flask(__name__) @@ -8,7 +9,8 @@ def index(): try: host_name = socket.gethostname() host_ip = socket.gethostbyname(host_name) - return render_template('index.html', hostname=host_name, ip=host_ip) + pass=(os.environ['PASSWORD']) + return render_template('index.html', hostname=host_name, ip=host_ip, secret=pass) except: return render_template('error.html') From a079e89b2aa5d00567ea0a8b0439f059e09eb6d4 Mon Sep 17 00:00:00 2001 From: Gelevb <48049770+Gelevb@users.noreply.github.com> Date: Tue, 21 Jul 2020 09:31:45 +0300 Subject: [PATCH 02/12] Update index.html --- app/templates/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/templates/index.html b/app/templates/index.html index 63ed175b..d3ba67af 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -6,5 +6,6 @@ The hostname of the container is {{ hostname }} and its IP is {{ ip }}. + And the secret is: {{ secret }} - \ No newline at end of file + From b4125c1d46a16159855169aaf1d244d6be7a0be9 Mon Sep 17 00:00:00 2001 From: gelevb Date: Tue, 21 Jul 2020 09:32:04 +0300 Subject: [PATCH 03/12] Draft create --- .dockerignore | 5 ++ .helmignore | 27 +++++++ OWNERS | 4 + OWNERS_ALIASES | 6 ++ charts/preview/Chart.yaml | 5 ++ charts/preview/Makefile | 18 +++++ charts/preview/requirements.yaml | 16 ++++ charts/preview/values.yaml | 22 +++++ charts/python-demo/.helmignore | 21 +++++ charts/python-demo/Chart.yaml | 4 + charts/python-demo/Makefile | 48 +++++++++++ charts/python-demo/templates/NOTES.txt | 15 ++++ charts/python-demo/templates/_helpers.tpl | 16 ++++ charts/python-demo/templates/canary.yaml | 85 ++++++++++++++++++++ charts/python-demo/templates/deployment.yaml | 43 ++++++++++ charts/python-demo/templates/hpa.yaml | 25 ++++++ charts/python-demo/templates/ingress.yaml | 17 ++++ charts/python-demo/templates/ksvc.yaml | 41 ++++++++++ charts/python-demo/templates/service.yaml | 26 ++++++ charts/python-demo/values.yaml | 73 +++++++++++++++++ jenkins-x.yml | 1 + skaffold.yaml | 28 +++++++ 22 files changed, 546 insertions(+) create mode 100644 .dockerignore create mode 100644 .helmignore create mode 100644 OWNERS create mode 100644 OWNERS_ALIASES create mode 100644 charts/preview/Chart.yaml create mode 100755 charts/preview/Makefile create mode 100755 charts/preview/requirements.yaml create mode 100755 charts/preview/values.yaml create mode 100755 charts/python-demo/.helmignore create mode 100644 charts/python-demo/Chart.yaml create mode 100755 charts/python-demo/Makefile create mode 100755 charts/python-demo/templates/NOTES.txt create mode 100755 charts/python-demo/templates/_helpers.tpl create mode 100755 charts/python-demo/templates/canary.yaml create mode 100755 charts/python-demo/templates/deployment.yaml create mode 100755 charts/python-demo/templates/hpa.yaml create mode 100755 charts/python-demo/templates/ingress.yaml create mode 100755 charts/python-demo/templates/ksvc.yaml create mode 100755 charts/python-demo/templates/service.yaml create mode 100755 charts/python-demo/values.yaml create mode 100755 jenkins-x.yml create mode 100644 skaffold.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..76f28a81 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +draft.toml +charts/ +NOTICE +LICENSE +README.md diff --git a/.helmignore b/.helmignore new file mode 100644 index 00000000..747e6e94 --- /dev/null +++ b/.helmignore @@ -0,0 +1,27 @@ +# 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 +*.png + +# known compile time folders +target/ +node_modules/ +vendor/ \ No newline at end of file diff --git a/OWNERS b/OWNERS new file mode 100644 index 00000000..c635c889 --- /dev/null +++ b/OWNERS @@ -0,0 +1,4 @@ +approvers: +- gelevb +reviewers: +- gelevb diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES new file mode 100644 index 00000000..687f611e --- /dev/null +++ b/OWNERS_ALIASES @@ -0,0 +1,6 @@ +aliases: +- gelevb +best-approvers: +- gelevb +best-reviewers: +- gelevb diff --git a/charts/preview/Chart.yaml b/charts/preview/Chart.yaml new file mode 100644 index 00000000..35e5bd86 --- /dev/null +++ b/charts/preview/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +icon: https://raw.githubusercontent.com/jenkins-x/jenkins-x-platform/master/images/python.png +name: preview +version: 0.1.0-SNAPSHOT diff --git a/charts/preview/Makefile b/charts/preview/Makefile new file mode 100755 index 00000000..1a2e1212 --- /dev/null +++ b/charts/preview/Makefile @@ -0,0 +1,18 @@ +OS := $(shell uname) + +preview: +ifeq ($(OS),Darwin) + sed -i "" -e "s/version:.*/version: $(PREVIEW_VERSION)/" Chart.yaml + sed -i "" -e "s/version:.*/version: $(PREVIEW_VERSION)/" ../*/Chart.yaml + sed -i "" -e "s/tag:.*/tag: $(PREVIEW_VERSION)/" values.yaml +else ifeq ($(OS),Linux) + sed -i -e "s/version:.*/version: $(PREVIEW_VERSION)/" Chart.yaml + sed -i -e "s/version:.*/version: $(PREVIEW_VERSION)/" ../*/Chart.yaml + sed -i -e "s|repository:.*|repository: $(DOCKER_REGISTRY)\/gelevb\/python-demo|" values.yaml + sed -i -e "s/tag:.*/tag: $(PREVIEW_VERSION)/" values.yaml +else + echo "platfrom $(OS) not supported to release from" + exit -1 +endif + echo " version: $(PREVIEW_VERSION)" >> requirements.yaml + jx step helm build diff --git a/charts/preview/requirements.yaml b/charts/preview/requirements.yaml new file mode 100755 index 00000000..bb5314b7 --- /dev/null +++ b/charts/preview/requirements.yaml @@ -0,0 +1,16 @@ +# !! File must end with empty line !! +dependencies: +- alias: expose + name: exposecontroller + repository: http://chartmuseum.jenkins-x.io + version: 2.3.92 +- alias: cleanup + name: exposecontroller + repository: http://chartmuseum.jenkins-x.io + version: 2.3.92 + + # !! "alias: preview" must be last entry in dependencies array !! + # !! Place custom dependencies above !! +- alias: preview + name: python-demo + repository: file://../python-demo diff --git a/charts/preview/values.yaml b/charts/preview/values.yaml new file mode 100755 index 00000000..b53ceaa5 --- /dev/null +++ b/charts/preview/values.yaml @@ -0,0 +1,22 @@ + +expose: + Annotations: + helm.sh/hook: post-install,post-upgrade + helm.sh/hook-delete-policy: hook-succeeded + config: + exposer: Ingress + http: true + tlsacme: false + +cleanup: + Args: + - --cleanup + Annotations: + helm.sh/hook: pre-delete + helm.sh/hook-delete-policy: hook-succeeded + +preview: + image: + repository: + tag: + pullPolicy: IfNotPresent \ No newline at end of file diff --git a/charts/python-demo/.helmignore b/charts/python-demo/.helmignore new file mode 100755 index 00000000..f0c13194 --- /dev/null +++ b/charts/python-demo/.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/charts/python-demo/Chart.yaml b/charts/python-demo/Chart.yaml new file mode 100644 index 00000000..e29490bc --- /dev/null +++ b/charts/python-demo/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: python-demo +version: v0.1.0 diff --git a/charts/python-demo/Makefile b/charts/python-demo/Makefile new file mode 100755 index 00000000..188064d1 --- /dev/null +++ b/charts/python-demo/Makefile @@ -0,0 +1,48 @@ +CHART_REPO := http://jenkins-x-chartmuseum:8080 +CURRENT=$(pwd) +NAME := python-demo +OS := $(shell uname) +RELEASE_VERSION := $(shell cat ../../VERSION) + +build: clean + rm -rf requirements.lock + helm dependency build + helm lint + +install: clean build + helm install . --name ${NAME} + +upgrade: clean build + helm upgrade ${NAME} . + +delete: + helm delete --purge ${NAME} + +clean: + rm -rf charts + rm -rf ${NAME}*.tgz + +release: clean + helm dependency build + helm lint + helm init --client-only + helm package . + curl --fail -u $(CHARTMUSEUM_CREDS_USR):$(CHARTMUSEUM_CREDS_PSW) --data-binary "@$(NAME)-$(shell sed -n 's/^version: //p' Chart.yaml).tgz" $(CHART_REPO)/api/charts + rm -rf ${NAME}*.tgz% + +tag: +ifeq ($(OS),Darwin) + sed -i "" -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml + sed -i "" -e "s/tag:.*/tag: $(RELEASE_VERSION)/" values.yaml +else ifeq ($(OS),Linux) + sed -i -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml + sed -i -e "s|repository:.*|repository: $(DOCKER_REGISTRY)\/gelevb\/python-demo|" values.yaml + sed -i -e "s/tag:.*/tag: $(RELEASE_VERSION)/" values.yaml +else + echo "platfrom $(OS) not supported to release from" + exit -1 +endif + git add --all + git commit -m "release $(RELEASE_VERSION)" --allow-empty # if first release then no verion update is performed + git tag -fa v$(RELEASE_VERSION) -m "Release version $(RELEASE_VERSION)" + git push origin v$(RELEASE_VERSION) diff --git a/charts/python-demo/templates/NOTES.txt b/charts/python-demo/templates/NOTES.txt new file mode 100755 index 00000000..da948fa2 --- /dev/null +++ b/charts/python-demo/templates/NOTES.txt @@ -0,0 +1,15 @@ + +{{- if contains "NodePort" .Values.service.type }} + Get the application URL by running these commands: + 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/login +{{- else if contains "LoadBalancer" .Values.service.type }} + Get the application URL by running these commands: + 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 }} + http://{{ .Release.Name }}.{{ .Values.basedomain }} to access your application +{{- end }} diff --git a/charts/python-demo/templates/_helpers.tpl b/charts/python-demo/templates/_helpers.tpl new file mode 100755 index 00000000..f0d83d2e --- /dev/null +++ b/charts/python-demo/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/charts/python-demo/templates/canary.yaml b/charts/python-demo/templates/canary.yaml new file mode 100755 index 00000000..c65b1311 --- /dev/null +++ b/charts/python-demo/templates/canary.yaml @@ -0,0 +1,85 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1beta1 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + analysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: latency + templateRef: + name: latency + thresholdRange: + max: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: flagger.app/v1beta1 +kind: MetricTemplate +metadata: + name: latency +spec: + provider: + type: prometheus + address: http://prometheus.istio-system:9090 + query: | + histogram_quantile( + 0.99, + sum( + rate( + istio_request_duration_milliseconds_bucket{ + reporter="destination", + destination_workload_namespace="{{ "{{" }} namespace {{ "}}" }}", + destination_workload=~"{{ "{{" }} target {{ "}}" }}" + }[{{ "{{" }} interval {{ "}}" }}] + ) + ) by (le) + ) + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/charts/python-demo/templates/deployment.yaml b/charts/python-demo/templates/deployment.yaml new file mode 100755 index 00000000..fb25128a --- /dev/null +++ b/charts/python-demo/templates/deployment.yaml @@ -0,0 +1,43 @@ +{{- if .Values.knativeDeploy }} +{{- else }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + selector: + matchLabels: + app: {{ template "fullname" . }} +{{- if .Values.hpa.enabled }} +{{- else }} + replicas: {{ .Values.replicaCount }} +{{- end }} + template: + metadata: + labels: + draft: {{ default "draft-app" .Values.draft }} + app: {{ template "fullname" . }} +{{- if .Values.podAnnotations }} + annotations: +{{ toYaml .Values.podAnnotations | indent 8 }} +{{- end }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: +{{- range $pkey, $pval := .Values.env }} + - name: {{ $pkey }} + value: {{ quote $pval }} +{{- end }} + envFrom: +{{ toYaml .Values.envFrom | indent 10 }} + ports: + - containerPort: {{ .Values.service.internalPort }} + resources: +{{ toYaml .Values.resources | indent 12 }} +{{- end }} diff --git a/charts/python-demo/templates/hpa.yaml b/charts/python-demo/templates/hpa.yaml new file mode 100755 index 00000000..1c03eb4c --- /dev/null +++ b/charts/python-demo/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/charts/python-demo/templates/ingress.yaml b/charts/python-demo/templates/ingress.yaml new file mode 100755 index 00000000..3598ac6f --- /dev/null +++ b/charts/python-demo/templates/ingress.yaml @@ -0,0 +1,17 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: {{ template "fullname" . }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.basedomain }} + http: + paths: + - path: / + backend: + serviceName: {{ template "fullname" . }} + servicePort: {{ .Values.service.externalPort }} +{{- end -}} diff --git a/charts/python-demo/templates/ksvc.yaml b/charts/python-demo/templates/ksvc.yaml new file mode 100755 index 00000000..d37fb3f8 --- /dev/null +++ b/charts/python-demo/templates/ksvc.yaml @@ -0,0 +1,41 @@ +{{- if .Values.knativeDeploy }} +apiVersion: serving.knative.dev/v1alpha1 +kind: Service +metadata: +{{- if .Values.service.name }} + name: {{ .Values.service.name }} +{{- else }} + name: {{ template "fullname" . }} +{{- end }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + runLatest: + configuration: + revisionTemplate: + spec: + container: + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: +{{- range $pkey, $pval := .Values.env }} + - name: {{ $pkey }} + value: {{ quote $pval }} +{{- end }} + livenessProbe: + httpGet: + path: {{ .Values.probePath }} + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.livenessProbe.periodSeconds }} + successThreshold: {{ .Values.livenessProbe.successThreshold }} + timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} + readinessProbe: + failureThreshold: {{ .Values.readinessProbe.failureThreshold }} + httpGet: + path: {{ .Values.probePath }} + periodSeconds: {{ .Values.readinessProbe.periodSeconds }} + successThreshold: {{ .Values.readinessProbe.successThreshold }} + timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} + resources: +{{ toYaml .Values.resources | indent 14 }} +{{- end }} diff --git a/charts/python-demo/templates/service.yaml b/charts/python-demo/templates/service.yaml new file mode 100755 index 00000000..9a2a4c75 --- /dev/null +++ b/charts/python-demo/templates/service.yaml @@ -0,0 +1,26 @@ +{{- if or .Values.knativeDeploy .Values.canary.enabled }} +{{- else }} +apiVersion: v1 +kind: Service +metadata: +{{- if .Values.service.name }} + name: {{ .Values.service.name }} +{{- else }} + name: {{ template "fullname" . }} +{{- end }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +{{- if .Values.service.annotations }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} +{{- end }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + protocol: TCP + name: http + selector: + app: {{ template "fullname" . }} +{{- end }} diff --git a/charts/python-demo/values.yaml b/charts/python-demo/values.yaml new file mode 100755 index 00000000..ac2273be --- /dev/null +++ b/charts/python-demo/values.yaml @@ -0,0 +1,73 @@ +# Default values for python. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +image: + repository: draft + tag: dev + pullPolicy: IfNotPresent + +# define environment variables here as a map of key: value +env: + +# enable this flag to use knative serve to deploy the app +knativeDeploy: false + +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio v1.5+ and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + +service: + name: python-demo + type: ClusterIP + externalPort: 80 + internalPort: 8080 + annotations: + fabric8.io/expose: "true" + fabric8.io/ingress.annotations: "kubernetes.io/ingress.class: nginx" +resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi +ingress: + enabled: false +probePath: / +livenessProbe: + initialDelaySeconds: 60 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 +readinessProbe: + failureThreshold: 1 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 diff --git a/jenkins-x.yml b/jenkins-x.yml new file mode 100755 index 00000000..a6798322 --- /dev/null +++ b/jenkins-x.yml @@ -0,0 +1 @@ +buildPack: python diff --git a/skaffold.yaml b/skaffold.yaml new file mode 100644 index 00000000..e6639aa5 --- /dev/null +++ b/skaffold.yaml @@ -0,0 +1,28 @@ +apiVersion: skaffold/v1beta2 +kind: Config +build: + artifacts: + - image: gelevb/python-demo + context: . + docker: {} + tagPolicy: + envTemplate: + template: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}:{{.VERSION}}' + local: {} +deploy: + kubectl: {} +profiles: +- name: dev + build: + tagPolicy: + envTemplate: + template: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}:{{.DIGEST_HEX}}' + local: {} + deploy: + helm: + releases: + - name: python-demo + chartPath: charts/python-demo + setValueTemplates: + image.repository: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}' + image.tag: '{{.DIGEST_HEX}}' From 4343a9a372eca9fecf37885fe1f2df1b6fab174e Mon Sep 17 00:00:00 2001 From: Gelevb <48049770+Gelevb@users.noreply.github.com> Date: Tue, 21 Jul 2020 09:40:48 +0300 Subject: [PATCH 04/12] Update app.py --- app/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.py b/app/app.py index 2e03b32f..f4f178e4 100644 --- a/app/app.py +++ b/app/app.py @@ -9,7 +9,7 @@ def index(): try: host_name = socket.gethostname() host_ip = socket.gethostbyname(host_name) - pass=(os.environ['PASSWORD']) + pass = (os.environ['PASSWORD']) return render_template('index.html', hostname=host_name, ip=host_ip, secret=pass) except: return render_template('error.html') From f72f0a87a0b42b2a41c7c0343da6de9928a70b52 Mon Sep 17 00:00:00 2001 From: Gelevb <48049770+Gelevb@users.noreply.github.com> Date: Tue, 21 Jul 2020 09:49:25 +0300 Subject: [PATCH 05/12] Update app.py --- app/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/app.py b/app/app.py index f4f178e4..f2b656af 100644 --- a/app/app.py +++ b/app/app.py @@ -9,8 +9,8 @@ def index(): try: host_name = socket.gethostname() host_ip = socket.gethostbyname(host_name) - pass = (os.environ['PASSWORD']) - return render_template('index.html', hostname=host_name, ip=host_ip, secret=pass) + secret = (os.environ['PASSWORD']) + return render_template('index.html', hostname=host_name, ip=host_ip, secret=secret) except: return render_template('error.html') From 0b18120539bec90adf60b8ba98a69be7ba3f7cca Mon Sep 17 00:00:00 2001 From: Gelevb <48049770+Gelevb@users.noreply.github.com> Date: Tue, 21 Jul 2020 10:26:39 +0300 Subject: [PATCH 06/12] Update app.py --- app/app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/app.py b/app/app.py index f2b656af..ff1a2cb3 100644 --- a/app/app.py +++ b/app/app.py @@ -15,5 +15,6 @@ def index(): return render_template('error.html') + if __name__ == "__main__": app.run(host='0.0.0.0', port=8080) From a2c6c59baeeffd7d92c60fb7bd43a57d5f019954 Mon Sep 17 00:00:00 2001 From: Gelevb <48049770+Gelevb@users.noreply.github.com> Date: Tue, 21 Jul 2020 11:54:38 +0300 Subject: [PATCH 07/12] Update app.py --- app/app.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/app.py b/app/app.py index ff1a2cb3..37431ed4 100644 --- a/app/app.py +++ b/app/app.py @@ -16,5 +16,7 @@ def index(): + + if __name__ == "__main__": app.run(host='0.0.0.0', port=8080) From 9f11e2d09d6906af8b4cd4783a658ba54d310c46 Mon Sep 17 00:00:00 2001 From: gelevb Date: Tue, 21 Jul 2020 13:31:19 +0300 Subject: [PATCH 08/12] secrets update --- charts/python-demo/templates/mysecrets.yaml | 6 ++++++ charts/python-demo/values.yaml | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 charts/python-demo/templates/mysecrets.yaml diff --git a/charts/python-demo/templates/mysecrets.yaml b/charts/python-demo/templates/mysecrets.yaml new file mode 100644 index 00000000..2deace2a --- /dev/null +++ b/charts/python-demo/templates/mysecrets.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Secret +metadata: + name: mysecrets +data: + PASSWORD: {{ .Values.mysecrets.password | b64enc }} \ No newline at end of file diff --git a/charts/python-demo/values.yaml b/charts/python-demo/values.yaml index ac2273be..f327a359 100755 --- a/charts/python-demo/values.yaml +++ b/charts/python-demo/values.yaml @@ -71,3 +71,6 @@ readinessProbe: periodSeconds: 10 successThreshold: 1 timeoutSeconds: 1 + +mysecrets: + password: "" \ No newline at end of file From 700367c7eebf7a665a54f174db266a874dd425f9 Mon Sep 17 00:00:00 2001 From: gelevb Date: Tue, 21 Jul 2020 13:37:12 +0300 Subject: [PATCH 09/12] secrets mount --- charts/python-demo/templates/deployment.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/python-demo/templates/deployment.yaml b/charts/python-demo/templates/deployment.yaml index fb25128a..12da701a 100755 --- a/charts/python-demo/templates/deployment.yaml +++ b/charts/python-demo/templates/deployment.yaml @@ -36,6 +36,8 @@ spec: {{- end }} envFrom: {{ toYaml .Values.envFrom | indent 10 }} + - secretRef: + name: mysecrets ports: - containerPort: {{ .Values.service.internalPort }} resources: From 4a66812c43233aa60c17d07bf11b75b8168b256e Mon Sep 17 00:00:00 2001 From: gelevb Date: Tue, 21 Jul 2020 13:43:24 +0300 Subject: [PATCH 10/12] secrets mount --- charts/python-demo/templates/deployment.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/charts/python-demo/templates/deployment.yaml b/charts/python-demo/templates/deployment.yaml index 12da701a..b4837468 100755 --- a/charts/python-demo/templates/deployment.yaml +++ b/charts/python-demo/templates/deployment.yaml @@ -27,6 +27,9 @@ spec: spec: containers: - name: {{ .Chart.Name }} + envFrom: + - secretRef: + name: mysecrets image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} env: @@ -36,8 +39,6 @@ spec: {{- end }} envFrom: {{ toYaml .Values.envFrom | indent 10 }} - - secretRef: - name: mysecrets ports: - containerPort: {{ .Values.service.internalPort }} resources: From faad754cee788568264ad2fcae642551dc6b4b50 Mon Sep 17 00:00:00 2001 From: gelevb Date: Tue, 21 Jul 2020 13:53:50 +0300 Subject: [PATCH 11/12] secrets mount update --- charts/python-demo/templates/deployment.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/charts/python-demo/templates/deployment.yaml b/charts/python-demo/templates/deployment.yaml index b4837468..25e9eb88 100755 --- a/charts/python-demo/templates/deployment.yaml +++ b/charts/python-demo/templates/deployment.yaml @@ -37,8 +37,6 @@ spec: - name: {{ $pkey }} value: {{ quote $pval }} {{- end }} - envFrom: -{{ toYaml .Values.envFrom | indent 10 }} ports: - containerPort: {{ .Values.service.internalPort }} resources: From 5c4a5b7870fe02054208379756bc939b37389e45 Mon Sep 17 00:00:00 2001 From: gelevb Date: Tue, 21 Jul 2020 14:26:03 +0300 Subject: [PATCH 12/12] secret update --- charts/python-demo/templates/mysecrets.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/python-demo/templates/mysecrets.yaml b/charts/python-demo/templates/mysecrets.yaml index 2deace2a..4d808164 100644 --- a/charts/python-demo/templates/mysecrets.yaml +++ b/charts/python-demo/templates/mysecrets.yaml @@ -3,4 +3,4 @@ kind: Secret metadata: name: mysecrets data: - PASSWORD: {{ .Values.mysecrets.password | b64enc }} \ No newline at end of file + SECRET: {{ .Values.mysecrets.password | b64enc }} \ No newline at end of file