From 074f290b401d87578b735d1d4320853ac6d4e897 Mon Sep 17 00:00:00 2001 From: targs08 Date: Mon, 26 Apr 2021 00:07:52 +0300 Subject: [PATCH] Implement youtrack chart (#2) * Add github actions workflow * Update input arguments for chart-releaser workflow * Switch workflow to master bracnh * Chang notify email * Update hcloud-controlle-manager and mark as Deprecated * Add gitignore * Implement youtrack chart --- .gitignore | 1 + .../fleetlock/templates/serviceAccount.yaml | 10 ++ .../Chart.yaml | 4 +- .../templates/_helpers.tpl | 2 +- .../templates/clusterRoleBinding.yaml | 5 +- .../{deployment.yaml => daemonSet.yaml} | 7 +- .../templates/secret.yaml | 2 +- .../values.yaml | 2 + stable/youtrack/.helmignore | 23 +++++ stable/youtrack/Chart.yaml | 24 +++++ stable/youtrack/templates/NOTES.txt | 22 +++++ stable/youtrack/templates/_helpers.tpl | 62 +++++++++++++ stable/youtrack/templates/ingress.yaml | 44 +++++++++ stable/youtrack/templates/service.yaml | 13 +++ stable/youtrack/templates/serviceaccount.yaml | 10 ++ stable/youtrack/templates/statefulset.yaml | 87 +++++++++++++++++ .../templates/tests/test-connection.yaml | 15 +++ stable/youtrack/values.yaml | 93 +++++++++++++++++++ 18 files changed, 418 insertions(+), 8 deletions(-) create mode 100644 .gitignore create mode 100644 stable/fleetlock/templates/serviceAccount.yaml rename stable/hcloud-cloud-controller-manager/templates/{deployment.yaml => daemonSet.yaml} (94%) create mode 100644 stable/youtrack/.helmignore create mode 100644 stable/youtrack/Chart.yaml create mode 100644 stable/youtrack/templates/NOTES.txt create mode 100644 stable/youtrack/templates/_helpers.tpl create mode 100644 stable/youtrack/templates/ingress.yaml create mode 100644 stable/youtrack/templates/service.yaml create mode 100644 stable/youtrack/templates/serviceaccount.yaml create mode 100644 stable/youtrack/templates/statefulset.yaml create mode 100644 stable/youtrack/templates/tests/test-connection.yaml create mode 100644 stable/youtrack/values.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/stable/fleetlock/templates/serviceAccount.yaml b/stable/fleetlock/templates/serviceAccount.yaml new file mode 100644 index 0000000..1f13889 --- /dev/null +++ b/stable/fleetlock/templates/serviceAccount.yaml @@ -0,0 +1,10 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "fleetlock.serviceAccountName" . }} + labels: {{- include "fleetlock.labels" . | nindent 4 }} +{{- with .Values.serviceAccount.annotations }} + annotations: {{- toYaml . | nindent 4 }} +{{- end }} +{{- end }} diff --git a/stable/hcloud-cloud-controller-manager/Chart.yaml b/stable/hcloud-cloud-controller-manager/Chart.yaml index 7e64859..adfc526 100644 --- a/stable/hcloud-cloud-controller-manager/Chart.yaml +++ b/stable/hcloud-cloud-controller-manager/Chart.yaml @@ -2,6 +2,8 @@ apiVersion: v2 name: hcloud-cloud-controller-manager description: A Helm chart for Kubernetes +deprecated: true + # A chart can be either an 'application' or a 'library' chart. # # Application charts are a collection of templates that can be packaged into versioned archives @@ -11,7 +13,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.1 +version: 0.1.2 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/stable/hcloud-cloud-controller-manager/templates/_helpers.tpl b/stable/hcloud-cloud-controller-manager/templates/_helpers.tpl index 8698534..5b2e906 100644 --- a/stable/hcloud-cloud-controller-manager/templates/_helpers.tpl +++ b/stable/hcloud-cloud-controller-manager/templates/_helpers.tpl @@ -2,7 +2,7 @@ Expand the name of the chart. */}} {{- define "hcloud-cloud-controller-manager.name" -}} -aws-cloud-controller-manager +hcloud-cloud-controller-manager {{- end }} {{/* diff --git a/stable/hcloud-cloud-controller-manager/templates/clusterRoleBinding.yaml b/stable/hcloud-cloud-controller-manager/templates/clusterRoleBinding.yaml index 54687a0..6fbcf4d 100644 --- a/stable/hcloud-cloud-controller-manager/templates/clusterRoleBinding.yaml +++ b/stable/hcloud-cloud-controller-manager/templates/clusterRoleBinding.yaml @@ -1,12 +1,13 @@ kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: {{ include "hcloud-cloud-controller-manager.serviceAccountName" . }} + name: {{ printf "system:%s" (include "hcloud-cloud-controller-manager.serviceAccountName" .) }} labels: {{- include "hcloud-cloud-controller-manager.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: {{ include "hcloud-cloud-controller-manager.serviceAccountName" . }} + name: cluster-admin + # name: {{ include "hcloud-cloud-controller-manager.serviceAccountName" . }} subjects: - apiGroup: "" kind: ServiceAccount diff --git a/stable/hcloud-cloud-controller-manager/templates/deployment.yaml b/stable/hcloud-cloud-controller-manager/templates/daemonSet.yaml similarity index 94% rename from stable/hcloud-cloud-controller-manager/templates/deployment.yaml rename to stable/hcloud-cloud-controller-manager/templates/daemonSet.yaml index 95506c2..fe02f18 100644 --- a/stable/hcloud-cloud-controller-manager/templates/deployment.yaml +++ b/stable/hcloud-cloud-controller-manager/templates/daemonSet.yaml @@ -1,10 +1,11 @@ apiVersion: apps/v1 -kind: Deployment +kind: DaemonSet metadata: name: {{ include "hcloud-cloud-controller-manager.fullname" . }} labels: {{- include "hcloud-cloud-controller-manager.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicas }} + updateStrategy: + type: {{ .Values.updateStrategy.type }} selector: matchLabels: {{- include "hcloud-cloud-controller-manager.selectorLabels" . | nindent 6 }} template: @@ -36,7 +37,7 @@ spec: args: - --leader-elect=true {{- if .Values.networkSupport.enabled }} - - --allocate-node-cidrs=true" + - --allocate-node-cidrs=true - --cluster-cidr={{ .Values.networkSupport.cluserCIDR }} {{- end }} {{- with .Values.args }} diff --git a/stable/hcloud-cloud-controller-manager/templates/secret.yaml b/stable/hcloud-cloud-controller-manager/templates/secret.yaml index b2ae941..f30c708 100644 --- a/stable/hcloud-cloud-controller-manager/templates/secret.yaml +++ b/stable/hcloud-cloud-controller-manager/templates/secret.yaml @@ -1,7 +1,7 @@ kind: Secret apiVersion: v1 metadata: - name: {{ include "hcloud-cloud-controller-manager.serviceAccountName" . }} + name: {{ include "hcloud-cloud-controller-manager.fullname" . }} labels: {{- include "hcloud-cloud-controller-manager.labels" . | nindent 4 }} type: Opaque data: diff --git a/stable/hcloud-cloud-controller-manager/values.yaml b/stable/hcloud-cloud-controller-manager/values.yaml index 4df57c1..c9e1ca7 100644 --- a/stable/hcloud-cloud-controller-manager/values.yaml +++ b/stable/hcloud-cloud-controller-manager/values.yaml @@ -21,6 +21,8 @@ networkSupport: networkId: "" cluserCIDR: 10.244.0.0/16 +updateStrategy: + type: RollingUpdate # isClusterService specifies whether chart should be deployed as cluster-service or normal k8s app. isClusterService: true diff --git a/stable/youtrack/.helmignore b/stable/youtrack/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/stable/youtrack/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/stable/youtrack/Chart.yaml b/stable/youtrack/Chart.yaml new file mode 100644 index 0000000..7531f5d --- /dev/null +++ b/stable/youtrack/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: youtrack +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "2021.1.11513" diff --git a/stable/youtrack/templates/NOTES.txt b/stable/youtrack/templates/NOTES.txt new file mode 100644 index 0000000..2d4382b --- /dev/null +++ b/stable/youtrack/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "youtrack.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 --namespace {{ .Release.Namespace }} svc -w {{ include "youtrack.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "youtrack.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + 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.kubernetes.io/name={{ include "youtrack.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/stable/youtrack/templates/_helpers.tpl b/stable/youtrack/templates/_helpers.tpl new file mode 100644 index 0000000..318682e --- /dev/null +++ b/stable/youtrack/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "youtrack.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 "youtrack.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 }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "youtrack.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "youtrack.labels" -}} +helm.sh/chart: {{ include "youtrack.chart" . }} +{{ include "youtrack.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "youtrack.selectorLabels" -}} +app.kubernetes.io/name: {{ include "youtrack.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "youtrack.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "youtrack.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/stable/youtrack/templates/ingress.yaml b/stable/youtrack/templates/ingress.yaml new file mode 100644 index 0000000..e8abacb --- /dev/null +++ b/stable/youtrack/templates/ingress.yaml @@ -0,0 +1,44 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "youtrack.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "youtrack.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + pathType: Prefix + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} diff --git a/stable/youtrack/templates/service.yaml b/stable/youtrack/templates/service.yaml new file mode 100644 index 0000000..122cdaa --- /dev/null +++ b/stable/youtrack/templates/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "youtrack.fullname" . }} + labels: {{- include "youtrack.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: {{- include "youtrack.selectorLabels" . | nindent 4 }} diff --git a/stable/youtrack/templates/serviceaccount.yaml b/stable/youtrack/templates/serviceaccount.yaml new file mode 100644 index 0000000..6285cbb --- /dev/null +++ b/stable/youtrack/templates/serviceaccount.yaml @@ -0,0 +1,10 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "youtrack.serviceAccountName" . }} + labels: {{- include "youtrack.labels" . | nindent 4 }} +{{- with .Values.serviceAccount.annotations }} + annotations: {{- toYaml . | nindent 4 }} +{{- end }} +{{- end }} diff --git a/stable/youtrack/templates/statefulset.yaml b/stable/youtrack/templates/statefulset.yaml new file mode 100644 index 0000000..c1b22bf --- /dev/null +++ b/stable/youtrack/templates/statefulset.yaml @@ -0,0 +1,87 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "youtrack.fullname" . }} + labels: {{- include "youtrack.labels" . | nindent 4 }} +spec: + replicas: 1 + serviceName: {{ include "youtrack.fullname" . }} + updateStrategy: + type: RollingUpdate + selector: + matchLabels: {{- include "youtrack.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: {{- toYaml . | nindent 8 }} + {{- end }} + labels: {{- include "youtrack.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "youtrack.serviceAccountName" . }} + securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + tcpSocket: + port: 8080 + readinessProbe: + tcpSocket: + port: 8080 + volumeMounts: + - name: data + mountPath: /opt/youtrack/data + subPath: data + - name: data + mountPath: /opt/youtrack/conf + subPath: conf + - name: data + mountPath: /opt/youtrack/backups + subPath: backups + {{- if .Values.config.logPersistence }} + - name: data + mountPath: /opt/youtrack/logs + subPath: logs + {{- else }} + - name: logs + mountPath: /opt/youtrack/logs + {{- end }} + resources: {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + {{- if not .Values.persistence.enabled }} + - name: data + emptyDir: {} + {{- end }} + {{- if not .Values.config.logPersistence }} + - name: logs + emptyDir: {} + {{- end }} +{{- if .Values.persistence.enabled }} + volumeClaimTemplates: + - metadata: + name: data + spec: + accessModes: {{- toYaml (list .Values.persistence.accessMode) | nindent 10 }} + storageClassName: {{ .Values.persistence.storageClass }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- end }} \ No newline at end of file diff --git a/stable/youtrack/templates/tests/test-connection.yaml b/stable/youtrack/templates/tests/test-connection.yaml new file mode 100644 index 0000000..043b42c --- /dev/null +++ b/stable/youtrack/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "youtrack.fullname" . }}-test-connection" + labels: + {{- include "youtrack.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "youtrack.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/stable/youtrack/values.yaml b/stable/youtrack/values.yaml new file mode 100644 index 0000000..501a09b --- /dev/null +++ b/stable/youtrack/values.yaml @@ -0,0 +1,93 @@ +# Default values for youtrack. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: jetbrains/youtrack + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: + fsGroup: 13001 + +securityContext: + runAsNonRoot: true + runAsUser: 13001 + + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + +config: + logPersistence: false + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + + 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 + +## Persist data to a persistent volume +persistence: + enabled: false + + ## 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: "-" + # annotations: {} + accessMode: ReadWriteOnce + size: 10Gi + +nodeSelector: {} + +tolerations: [] + +affinity: {}