diff --git a/Jenkinsfile b/Jenkinsfile index 094b7be..2b835b2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { label "jenkins-gradle" } environment { - ORG = 'zmailloux' + ORG = 'zebra' APP_NAME = 'meta-project' CHARTMUSEUM_CREDS = credentials('jenkins-x-chartmuseum') } @@ -13,6 +13,7 @@ pipeline { branch 'PR-*' } environment { + DOCKER_REGISTRY = "gcr.io/es-devops-d" PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER" PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase() HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase() diff --git a/charts/meta-project/Chart.yaml b/charts/meta-project/Chart.yaml index 8b32423..a600230 100644 --- a/charts/meta-project/Chart.yaml +++ b/charts/meta-project/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 -appVersion: "1.0" +icon: https://raw.githubusercontent.com/jenkins-x/jenkins-x-platform/master/images/java.png description: A Helm chart for Kubernetes name: meta-project -version: 0.1.0 +version: 0.1.0-SNAPSHOT diff --git a/charts/meta-project/Makefile b/charts/meta-project/Makefile index 1472cc8..9b051ab 100755 --- a/charts/meta-project/Makefile +++ b/charts/meta-project/Makefile @@ -36,7 +36,7 @@ ifeq ($(OS),Darwin) 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)\/zmailloux\/meta-project|" values.yaml + sed -i -e "s|repository:.*|repository: $(DOCKER_REGISTRY)\/zebra\/meta-project|" values.yaml sed -i -e "s/tag:.*/tag: $(RELEASE_VERSION)/" values.yaml else echo "platfrom $(OS) not supported to release from" diff --git a/charts/meta-project/templates/NOTES.txt b/charts/meta-project/templates/NOTES.txt index 890dc66..f5a72a5 100644 --- a/charts/meta-project/templates/NOTES.txt +++ b/charts/meta-project/templates/NOTES.txt @@ -1,3 +1,19 @@ -Get the application URL by running these commands: - -kubectl get ingress {{ template "fullname" . }} \ No newline at end of file +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "meta-project.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 "meta-project.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "meta-project.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "meta-project.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:80 +{{- end }} diff --git a/charts/meta-project/templates/_helpers.tpl b/charts/meta-project/templates/_helpers.tpl index 6d29276..725b87a 100644 --- a/charts/meta-project/templates/_helpers.tpl +++ b/charts/meta-project/templates/_helpers.tpl @@ -2,7 +2,7 @@ {{/* Expand the name of the chart. */}} -{{- define "name" -}} +{{- define "meta-project.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} @@ -11,15 +11,22 @@ 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). If release name contains chart name it will be used as a full name. */}} - -{{- define "fullname" -}} +{{- define "meta-project.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} {{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{- end -}} +{{- end -}} - +{{- end -}} diff --git a/charts/meta-project/templates/deployment.yaml b/charts/meta-project/templates/deployment.yaml index 95cb9dc..a1e87b4 100644 --- a/charts/meta-project/templates/deployment.yaml +++ b/charts/meta-project/templates/deployment.yaml @@ -1,32 +1,46 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1beta2 kind: Deployment metadata: - name: {{ template "fullname" . }} + name: {{ template "meta-project.fullname" . }} labels: - draft: {{ default "draft-app" .Values.draft }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + app: {{ template "meta-project.name" . }} + chart: {{ template "meta-project.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} spec: replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "meta-project.name" . }} + release: {{ .Release.Name }} template: metadata: - labels: - draft: {{ default "draft-app" .Values.draft }} - app: {{ template "fullname" . }} -{{- if .Values.podAnnotations }} annotations: prometheus.io/scrape: "true" prometheus.io/port: "9001" prometheus.io/path: "/actuator/prometheus" -{{ toYaml .Values.podAnnotations | indent 8 }} -{{- end }} + labels: + app: {{ template "meta-project.name" . }} + release: {{ .Release.Name }} spec: containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 9001 - resources: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 9001 + resources: {{ toYaml .Values.resources | indent 12 }} - terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} \ No newline at end of file diff --git a/charts/meta-project/templates/ingress.yaml b/charts/meta-project/templates/ingress.yaml new file mode 100644 index 0000000..b659723 --- /dev/null +++ b/charts/meta-project/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "meta-project.fullname" . -}} +{{- $ingressPath := .Values.ingress.path -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "meta-project.name" . }} + chart: {{ template "meta-project.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . }} + {{- end }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: / + backend: + serviceName: {{ $fullName }} + servicePort: 9000 + - path: /external + backend: + serviceName: {{ $fullName }} + servicePort: 9001 + {{- end }} +{{- end }} diff --git a/charts/meta-project/templates/service.yaml b/charts/meta-project/templates/service.yaml index dc8fec2..ea1e7db 100644 --- a/charts/meta-project/templates/service.yaml +++ b/charts/meta-project/templates/service.yaml @@ -1,19 +1,13 @@ apiVersion: v1 kind: Service metadata: -{{- if .Values.service.name }} - name: {{ .Values.service.name }} -{{- else }} - name: {{ template "fullname" . }} -{{- end }} + name: {{ template "meta-project.fullname" . }} labels: - chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" -{{- if .Values.service.annotations }} - annotations: -{{ toYaml .Values.service.annotations | indent 4 }} -{{- end }} + app: {{ template "meta-project.name" . }} + chart: {{ template "meta-project.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} spec: - type: {{ .Values.service.type }} ports: - name: endpoints protocol: TCP @@ -22,4 +16,5 @@ spec: protocol: TCP port: 9001 selector: - app: {{ template "fullname" . }} \ No newline at end of file + app: {{ template "meta-project.name" . }} + release: {{ .Release.Name }} diff --git a/charts/meta-project/values.yaml b/charts/meta-project/values.yaml index d41afdc..01e33d9 100644 --- a/charts/meta-project/values.yaml +++ b/charts/meta-project/values.yaml @@ -1,19 +1,41 @@ +# Default values for meta-project. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + replicaCount: 1 + image: - repository: draft - tag: dev + repository: gcr.io/es-devops-d/zebra/meta-project + tag: latest pullPolicy: IfNotPresent -service: - name: meta-project - type: ClusterIP - annotations: - fabric8.io/expose: "true" - fabric8.io/ingress.annotations: "kubernetes.io/ingress.class: nginx" -resources: - limits: - cpu: 500m - memory: 512Mi - requests: - cpu: 400m - memory: 512Mi -terminationGracePeriodSeconds: 10 \ No newline at end of file + +ingress: + enabled: true + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + path: / + hosts: + - meta-project.dev.zebra.engineering + tls: [] + # - 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 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/preview/Makefile b/charts/preview/Makefile index 0135552..e84a622 100755 --- a/charts/preview/Makefile +++ b/charts/preview/Makefile @@ -8,7 +8,7 @@ ifeq ($(OS),Darwin) 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)\/zmailloux\/meta-project|" values.yaml + sed -i -e "s|repository:.*|repository: $(DOCKER_REGISTRY)\/zebra\/meta-project|" values.yaml sed -i -e "s/tag:.*/tag: $(PREVIEW_VERSION)/" values.yaml else echo "platfrom $(OS) not supported to release from" diff --git a/old-charts/meta-project/.helmignore b/old-charts/meta-project/.helmignore new file mode 100755 index 0000000..f0c1319 --- /dev/null +++ b/old-charts/meta-project/.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/old-charts/meta-project/Chart.yaml b/old-charts/meta-project/Chart.yaml new file mode 100644 index 0000000..8b32423 --- /dev/null +++ b/old-charts/meta-project/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: meta-project +version: 0.1.0 diff --git a/old-charts/meta-project/Makefile b/old-charts/meta-project/Makefile new file mode 100755 index 0000000..9b051ab --- /dev/null +++ b/old-charts/meta-project/Makefile @@ -0,0 +1,48 @@ +CHART_REPO := http://jenkins-x-chartmuseum:8080 +CURRENT=$(pwd) +NAME := meta-project +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)\/zebra\/meta-project|" 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/old-charts/meta-project/README.md b/old-charts/meta-project/README.md new file mode 100755 index 0000000..7c39461 --- /dev/null +++ b/old-charts/meta-project/README.md @@ -0,0 +1 @@ +# Java application \ No newline at end of file diff --git a/old-charts/meta-project/templates/NOTES.txt b/old-charts/meta-project/templates/NOTES.txt new file mode 100644 index 0000000..890dc66 --- /dev/null +++ b/old-charts/meta-project/templates/NOTES.txt @@ -0,0 +1,3 @@ +Get the application URL by running these commands: + +kubectl get ingress {{ template "fullname" . }} \ No newline at end of file diff --git a/old-charts/meta-project/templates/_helpers.tpl b/old-charts/meta-project/templates/_helpers.tpl new file mode 100644 index 0000000..6d29276 --- /dev/null +++ b/old-charts/meta-project/templates/_helpers.tpl @@ -0,0 +1,25 @@ +{{/* 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). +If release name contains chart name it will be used as a full name. +*/}} + +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} + + diff --git a/old-charts/meta-project/templates/deployment.yaml b/old-charts/meta-project/templates/deployment.yaml new file mode 100644 index 0000000..01baa92 --- /dev/null +++ b/old-charts/meta-project/templates/deployment.yaml @@ -0,0 +1,32 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + draft: {{ default "draft-app" .Values.draft }} + app: {{ template "fullname" . }} +{{- if .Values.podAnnotations }} + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9001" + prometheus.io/path: "/actuator/prometheus" +{{ toYaml .Values.podAnnotations | indent 8 }} +{{- end }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 9001 + resources: +{{ toYaml .Values.resources | indent 12 }} + terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} diff --git a/old-charts/meta-project/templates/service.yaml b/old-charts/meta-project/templates/service.yaml new file mode 100644 index 0000000..dc8fec2 --- /dev/null +++ b/old-charts/meta-project/templates/service.yaml @@ -0,0 +1,25 @@ +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: + - name: endpoints + protocol: TCP + port: 9000 + - name: prometheus + protocol: TCP + port: 9001 + selector: + app: {{ template "fullname" . }} \ No newline at end of file diff --git a/old-charts/meta-project/values.yaml b/old-charts/meta-project/values.yaml new file mode 100644 index 0000000..50fcd7e --- /dev/null +++ b/old-charts/meta-project/values.yaml @@ -0,0 +1,12 @@ +replicaCount: 1 +image: + repository: gcr.io/es-devops-d/meta-project + tag: lastest + pullPolicy: IfNotPresent +service: + name: meta-project + type: ClusterIP + annotations: + fabric8.io/expose: "true" + fabric8.io/ingress.annotations: "kubernetes.io/ingress.class: nginx" +terminationGracePeriodSeconds: 10 \ No newline at end of file diff --git a/skaffold.yaml b/skaffold.yaml index 27859e9..8ed0b16 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -7,7 +7,7 @@ build: docker: {} tagPolicy: envTemplate: - template: '{{.DOCKER_REGISTRY}}/zmailloux/meta-project:{{.VERSION}}' + template: '{{.DOCKER_REGISTRY}}/zebra/meta-project:{{.VERSION}}' local: {} deploy: kubectl: {} @@ -18,7 +18,7 @@ profiles: - docker: {} tagPolicy: envTemplate: - template: '{{.DOCKER_REGISTRY}}/zmailloux/meta-project:{{.DIGEST_HEX}}' + template: '{{.DOCKER_REGISTRY}}/zebra/meta-project:{{.DIGEST_HEX}}' local: {} deploy: helm: @@ -26,5 +26,5 @@ profiles: - name: meta-project chartPath: charts/meta-project setValueTemplates: - image.repository: '{{.DOCKER_REGISTRY}}/zmailloux/meta-project' + image.repository: '{{.DOCKER_REGISTRY}}/zebra/meta-project' image.tag: '{{.DIGEST_HEX}}'