diff --git a/.argo/deploy.yaml b/.argo/deploy.yaml new file mode 100644 index 00000000..ee4fa879 --- /dev/null +++ b/.argo/deploy.yaml @@ -0,0 +1,69 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + namespace: argo +spec: + entrypoint: main + serviceAccountName: argo-server + templates: + - name: main + steps: + - - name: checkout + templateRef: + name: cwft-git + template: checkout-with-gitops + clusterScope: true + arguments: + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: branch + value: '{{workflow.parameters.branch}}' + - name: gitUrlNoProtocol + value: '{{workflow.parameters.gitUrlNoProtocol}}' + - - name: get-initial-chart-version + templateRef: + name: cwft-helm + template: get-chart-version + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.checkout.outputs.artifacts.repo-source}}' + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: chartDir + value: 'charts/{{workflow.parameters.appName}}' + - - name: set-environment-version + templateRef: + name: cwft-helm + template: set-environment-version + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.checkout.outputs.artifacts.repo-source}}' + parameters: + - name: fullChartPath + value: 'registry/{{workflow.parameters.clusterName}}/components/{{workflow.parameters.environment}}/{{workflow.parameters.appName}}/Chart.yaml' + - name: chartVersion + value: '{{steps.get-initial-chart-version.outputs.result}}-rc.{{workflow.parameters.shortSha}}' + - name: environment + value: '{{workflow.parameters.environment}}' + - - name: commit + templateRef: + name: cwft-git + template: pull-commit-push + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.set-environment-version.outputs.artifacts.repo-source}}' + parameters: + - name: repoName + value: 'gitops' + - name: gitUrlNoProtocol + value: '{{workflow.parameters.gitUrlNoProtocol}}' + - name: commitMessage + value: 'setting {{workflow.parameters.appName}} {{workflow.parameters.environment}} to chart version {{steps.get-initial-chart-version.outputs.result}}-rc.{{workflow.parameters.shortSha}}' diff --git a/.argo/publish.yaml b/.argo/publish.yaml new file mode 100644 index 00000000..feab50f7 --- /dev/null +++ b/.argo/publish.yaml @@ -0,0 +1,84 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + namespace: argo +spec: + entrypoint: main + serviceAccountName: argo-server + templates: + - name: main + steps: + - - name: publish-container + templateRef: + name: cwft-kaniko + template: build-push + clusterScope: true + arguments: + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: branch + value: '{{workflow.parameters.branch}}' + - name: containerRegistryURL + value: '{{workflow.parameters.containerRegistryURL}}' + - name: gitUrlNoProtocol + value: '{{workflow.parameters.gitUrlNoProtocol}}' + - - name: checkout + templateRef: + name: cwft-git + template: checkout-with-gitops + clusterScope: true + arguments: + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: branch + value: '{{workflow.parameters.branch}}' + - name: gitUrlNoProtocol + value: '{{workflow.parameters.gitUrlNoProtocol}}' + - - name: get-initial-chart-version + templateRef: + name: cwft-helm + template: get-chart-version + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.checkout.outputs.artifacts.repo-source}}' + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: chartDir + value: 'charts/{{workflow.parameters.appName}}' + - - name: set-chart-versions + templateRef: + name: cwft-helm + template: set-chart-versions + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.checkout.outputs.artifacts.repo-source}}' + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: chartDir + value: 'charts/{{workflow.parameters.appName}}' + - name: chartVersion + value: '{{steps.get-initial-chart-version.outputs.result}}-rc.{{workflow.parameters.shortSha}}' + - name: shortSha + value: '{{workflow.parameters.shortSha}}' + - - name: publish-helm-chart + templateRef: + name: cwft-helm + template: publish-chart + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.set-chart-versions.outputs.artifacts.repo-source}}' + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: chartDir + value: 'charts/{{workflow.parameters.appName}}' diff --git a/.argo/release.yaml b/.argo/release.yaml new file mode 100644 index 00000000..cca2afd3 --- /dev/null +++ b/.argo/release.yaml @@ -0,0 +1,150 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +spec: + entrypoint: main + serviceAccountName: argo-server + templates: + - name: main + steps: + - - name: checkout + templateRef: + name: cwft-git + template: checkout-with-gitops + clusterScope: true + arguments: + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: branch + value: '{{workflow.parameters.branch}}' + - name: gitUrlNoProtocol + value: '{{workflow.parameters.gitUrlNoProtocol}}' + - - name: get-initial-chart-version + templateRef: + name: cwft-helm + template: get-chart-version + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.checkout.outputs.artifacts.repo-source}}' + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: chartDir + value: 'charts/{{workflow.parameters.appName}}' + - - name: set-chart-versions + templateRef: + name: cwft-helm + template: set-chart-versions + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.checkout.outputs.artifacts.repo-source}}' + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: chartDir + value: 'charts/{{workflow.parameters.appName}}' + - name: chartVersion + value: '{{steps.get-initial-chart-version.outputs.result}}' + - name: shortSha + value: '{{workflow.parameters.shortSha}}' + - - name: publish-helm-chart + templateRef: + name: cwft-helm + template: publish-chart + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.set-chart-versions.outputs.artifacts.repo-source}}' + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: chartDir + value: 'charts/{{workflow.parameters.appName}}' + - - name: set-environment-version + templateRef: + name: cwft-helm + template: set-environment-version + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.checkout.outputs.artifacts.repo-source}}' + parameters: + - name: fullChartPath + value: 'registry/{{workflow.parameters.clusterName}}/components/{{workflow.parameters.environment}}/{{workflow.parameters.appName}}/Chart.yaml' + - name: chartVersion + value: '{{steps.get-initial-chart-version.outputs.result}}' + - name: environment + value: '{{workflow.parameters.environment}}' + - - name: commit-production + templateRef: + name: cwft-git + template: pull-commit-push + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.set-environment-version.outputs.artifacts.repo-source}}' + parameters: + - name: repoName + value: 'gitops' + - name: gitUrlNoProtocol + value: '{{workflow.parameters.gitUrlNoProtocol}}' + - name: commitMessage + value: 'setting {{workflow.parameters.appName}} {{workflow.parameters.environment}} to chart version {{steps.get-initial-chart-version.outputs.result}}' + - - name: increment-chart-minor + templateRef: + name: cwft-helm + template: increment-chart-minor + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.set-environment-version.outputs.artifacts.repo-source}}' + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: chartDir + value: 'charts/{{workflow.parameters.appName}}' + - name: chartVersion + value: '{{steps.get-initial-chart-version.outputs.result}}' + - - name: get-published-chart-version + templateRef: + name: cwft-helm + template: get-chart-version + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.increment-chart-minor.outputs.artifacts.repo-source}}' + parameters: + - name: appName + value: '{{workflow.parameters.appName}}' + - name: chartDir + value: 'charts/{{workflow.parameters.appName}}' + - - name: commit-chart-increment + templateRef: + name: cwft-git + template: pull-commit-push + clusterScope: true + arguments: + artifacts: + - name: repo-source + from: '{{steps.increment-chart-minor.outputs.artifacts.repo-source}}' + parameters: + - name: repoName + value: '{{workflow.parameters.appName}}' + - name: gitUrlNoProtocol + value: '{{workflow.parameters.gitUrlNoProtocol}}' + - name: commitMessage + # Please, be careful updating this message, it must comply with: + # github skip ci rule: https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/ + # github skip ci rule: https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs + # gitlab skip ci rule: https://devops.stackexchange.com/questions/6809/is-there-a-ci-skip-option-in-gitlab-ci + # in case, the rule is disbaled or don't work this step will create a circular trigger of builds and bumps of version. + value: "[skip ci] [CI SKIP] setting {{workflow.parameters.appName}} {{workflow.parameters.environment}} to chart version {{steps.get-published-chart-version.outputs.result}}\n\nskip-checks:true" diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..457f0bf2 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,154 @@ +name: release +env: + ARGO_NAMESPACE: argo + ARGO_VERSION: v3.4.1 +on: + push: + branches: + - initial-ci-2 +jobs: + publish: + runs-on: self-hosted + steps: + - name: Setup Runner for Argo + run: | + cd $HOME + echo "Install argo" + # Download the binary + curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz + # Unzip + gunzip argo-linux-amd64.gz + # Make binary executable + chmod +x argo-linux-amd64 + # Move binary to path + sudo mv ./argo-linux-amd64 /usr/local/bin/argo + # Test installation + - name: Check out repository code + uses: actions/checkout@v3 + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v4 + - run: echo ${GITHUB_REPOSITORY} + - run: echo ${GITHUB_REPOSITORY_NAME_PART} + - run: echo ${GITHUB_SERVER_URL} + - name: publish + run: | + echo "commit sha ${GITHUB_SHA}" + argo version --short + argo submit .argo/publish.yaml \ + --generate-name="${GITHUB_REPOSITORY_NAME_PART}-publish-${GITHUB_SHA_SHORT}-" \ + -p appName="${GITHUB_REPOSITORY_NAME_PART}" \ + -p branch="${GITHUB_REF_NAME}" \ + -p containerRegistryURL="555935582951.dkr.ecr.us-east-2.amazonaws.com/${GITHUB_REPOSITORY_NAME_PART}:${GITHUB_SHA_SHORT}" \ + -p gitUrlNoProtocol="git@github.com:${GITHUB_REPOSITORY_OWNER_PART_SLUG}" \ + -p shortSha="${GITHUB_SHA_SHORT}" \ + --wait --log + - run: echo "⭐️ the kubefirst open source platform is powered by github stars. give kubefirst one today https://github.com/kubefirst/kubefirst" + development: + needs: publish + runs-on: self-hosted + steps: + - name: Setup Runner for Argo + run: | + cd $HOME + echo "Install argo" + # Download the binary + curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz + # Unzip + gunzip argo-linux-amd64.gz + # Make binary executable + chmod +x argo-linux-amd64 + # Move binary to path + sudo mv ./argo-linux-amd64 /usr/local/bin/argo + # Test installation + argo version --short + - name: Check out repository code + uses: actions/checkout@v3 + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v4 + - name: development + run: | + echo "commit sha $GITHUB_SHA" + argo version --short + argo submit .argo/deploy.yaml \ + --generate-name="${GITHUB_REPOSITORY_NAME_PART}-development-${GITHUB_SHA_SHORT}-" \ + -p appName="${GITHUB_REPOSITORY_NAME_PART}" \ + -p branch="${GITHUB_REF_NAME}" \ + -p clusterName="mgmt-20-kubefirst-com" \ + -p environment="development" \ + -p gitUrlNoProtocol="git@github.com:${GITHUB_REPOSITORY_OWNER_PART_SLUG}" \ + -p shortSha="${GITHUB_SHA_SHORT}" \ + --wait --log + - run: echo "⭐️ the kubefirst open source platform is powered by github stars. give kubefirst one today https://github.com/kubefirst/kubefirst" + staging: + needs: development + runs-on: self-hosted + steps: + - name: Setup Runner for Argo + run: | + cd $HOME + echo "Install argo" + # Download the binary + curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz + # Unzip + gunzip argo-linux-amd64.gz + # Make binary executable + chmod +x argo-linux-amd64 + # Move binary to path + sudo mv ./argo-linux-amd64 /usr/local/bin/argo + # Test installation + argo version --short + - name: Check out repository code + uses: actions/checkout@v3 + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v4 + - name: staging + run: | + echo "commit sha $GITHUB_SHA" + argo version --short + argo submit .argo/deploy.yaml \ + --generate-name="${GITHUB_REPOSITORY_NAME_PART}-staging-${GITHUB_SHA_SHORT}-" \ + -p appName="${GITHUB_REPOSITORY_NAME_PART}" \ + -p branch="${GITHUB_REF_NAME}" \ + -p clusterName="mgmt-20-kubefirst-com" \ + -p environment="staging" \ + -p gitUrlNoProtocol="git@github.com:${GITHUB_REPOSITORY_OWNER_PART_SLUG}" \ + -p shortSha="${GITHUB_SHA_SHORT}" \ + --wait --log + - run: echo "⭐️ the kubefirst open source platform is powered by github stars. give kubefirst one today https://github.com/kubefirst/kubefirst" + release: + needs: staging + runs-on: self-hosted + steps: + - name: Setup Runner for Argo + run: | + cd $HOME + echo "Install argo" + # Download the binary + curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz + # Unzip + gunzip argo-linux-amd64.gz + # Make binary executable + chmod +x argo-linux-amd64 + # Move binary to path + sudo mv ./argo-linux-amd64 /usr/local/bin/argo + # Test installation + argo version --short + - name: Check out repository code + uses: actions/checkout@v3 + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v4 + # todo need to look repositoryGitURL, this needs to be overrideable from here and respected on the template side for both repositories + - name: release + run: | + echo "commit sha $GITHUB_SHA" + argo version --short + argo submit .argo/release.yaml \ + --generate-name="${GITHUB_REPOSITORY_NAME_PART}-release-${GITHUB_SHA_SHORT}-" \ + -p appName="${GITHUB_REPOSITORY_NAME_PART}" \ + -p branch="${GITHUB_REF_NAME}" \ + -p clusterName="mgmt-20-kubefirst-com" \ + -p environment="production" \ + -p gitUrlNoProtocol="git@github.com:${GITHUB_REPOSITORY_OWNER_PART_SLUG}" \ + -p shortSha="${GITHUB_SHA_SHORT}" \ + --wait --log + - run: echo "⭐️ the kubefirst open source platform is powered by github stars. give kubefirst one today https://github.com/kubefirst/kubefirst" diff --git a/charts/console/.helmignore b/charts/console/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/console/.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/charts/console/Chart.yaml b/charts/console/Chart.yaml new file mode 100644 index 00000000..ba8dd8cd --- /dev/null +++ b/charts/console/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: console +description: A Helm chart for the Kubefirst Console + +# 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: 2.1.7 + +# 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: "2.1.7" diff --git a/charts/console/templates/NOTES.txt b/charts/console/templates/NOTES.txt new file mode 100644 index 00000000..0acdcf95 --- /dev/null +++ b/charts/console/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 "console.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 "console.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "console.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 "console.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/charts/console/templates/_helpers.tpl b/charts/console/templates/_helpers.tpl new file mode 100644 index 00000000..014c1d24 --- /dev/null +++ b/charts/console/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "console.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 "console.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 "console.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "console.labels" -}} +helm.sh/chart: {{ include "console.chart" . }} +{{ include "console.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "console.selectorLabels" -}} +app.kubernetes.io/name: {{ include "console.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "console.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "console.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/console/templates/deployment.yaml b/charts/console/templates/deployment.yaml new file mode 100644 index 00000000..74d5e00a --- /dev/null +++ b/charts/console/templates/deployment.yaml @@ -0,0 +1,75 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "console.fullname" . }} + labels: + {{- include "console.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "console.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "console.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "console.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + env: + {{- range $name, $item := .Values.env }} + - name: {{ $name }} + {{- $item | toYaml | nindent 14 }} + {{- end }} + 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 + initialDelaySeconds: 10 + periodSeconds: 5 + successThreshold: 1 + failureThreshold: 1 + timeoutSeconds: 30 + readinessProbe: + httpGet: + path: /api/healthz + port: http + initialDelaySeconds: 10 + periodSeconds: 5 + successThreshold: 1 + failureThreshold: 3 + timeoutSeconds: 30 + 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 }} diff --git a/charts/console/templates/hpa.yaml b/charts/console/templates/hpa.yaml new file mode 100644 index 00000000..8561f56a --- /dev/null +++ b/charts/console/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "console.fullname" . }} + labels: + {{- include "console.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "console.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/console/templates/ingress.yaml b/charts/console/templates/ingress.yaml new file mode 100644 index 00000000..e7ff2f95 --- /dev/null +++ b/charts/console/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "console.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "console.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- 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 }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/console/templates/service.yaml b/charts/console/templates/service.yaml new file mode 100644 index 00000000..986f2046 --- /dev/null +++ b/charts/console/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "console.fullname" . }} + labels: + {{- include "console.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "console.selectorLabels" . | nindent 4 }} diff --git a/charts/console/templates/serviceaccount.yaml b/charts/console/templates/serviceaccount.yaml new file mode 100644 index 00000000..cbe93f50 --- /dev/null +++ b/charts/console/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "console.serviceAccountName" . }} + labels: + {{- include "console.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/console/templates/tests/test-connection.yaml b/charts/console/templates/tests/test-connection.yaml new file mode 100644 index 00000000..1283ecc0 --- /dev/null +++ b/charts/console/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "console.fullname" . }}-test-connection" + labels: + {{- include "console.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "console.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/console/values.yaml b/charts/console/values.yaml new file mode 100644 index 00000000..05b74be6 --- /dev/null +++ b/charts/console/values.yaml @@ -0,0 +1,83 @@ +# Default values for console. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 555935582951.dkr.ecr.us-east-2.amazonaws.com + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "2.1.7" + +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: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 8080 + +ingress: + enabled: true + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: kubefirst.example.com + paths: + - path: / + pathType: ImplementationSpecific + 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 + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +env: []