This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Use helm charts, automate release (#42)
* Introduce helm chart for deploying Argo service Signed-off-by: Paolo Chila <paolo.chila@dynatrace.com> * Introduce pre-release and release workflows Signed-off-by: Paolo Chila <paolo.chila@dynatrace.com>
- Loading branch information
Showing
16 changed files
with
711 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Create Pre-Release | ||
on: | ||
workflow_dispatch: | ||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
- name: Unit tests | ||
uses: ./.github/actions/unit-tests | ||
|
||
pre-release: | ||
needs: test | ||
name: Pre-Release | ||
uses: keptn/gh-automation/.github/workflows/pre-release-integration.yml@v1.4.0 | ||
|
||
docker_build: | ||
needs: [pre-release] | ||
name: Docker Build | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2.4.0 | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Docker Build | ||
uses: keptn/gh-automation/.github/actions/docker-build@v1.4.0 | ||
with: | ||
TAGS: | | ||
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
BUILD_ARGS: | | ||
version=${{ env.VERSION }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }} | ||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
helm_chart_build: | ||
needs: [pre-release, docker_build] | ||
name: Build Helm Charts | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2.4.0 | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Build Helm Charts | ||
id: build_helm_charts | ||
run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}" | ||
|
||
- name: Upload Helm Chart as release asset | ||
env: | ||
RELEASE_TAG: ${{ needs.pre-release.outputs.RELEASE_TAG }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release upload "$RELEASE_TAG" installer/*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Create Release | ||
on: | ||
workflow_dispatch: | ||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
- name: Unit tests | ||
uses: ./.github/actions/unit-tests | ||
|
||
release: | ||
needs: test | ||
name: Release | ||
uses: keptn/gh-automation/.github/workflows/release-integration.yml@v1.4.0 | ||
|
||
docker_build: | ||
needs: [release] | ||
name: Docker Build | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2.4.0 | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Docker Build | ||
uses: keptn/gh-automation/.github/actions/docker-build@v1.4.0 | ||
with: | ||
TAGS: | | ||
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
BUILD_ARGS: | | ||
version=${{ env.VERSION }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }} | ||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
helm_chart_build: | ||
needs: [release, docker_build] | ||
|
||
name: Build Helm Charts | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v2.4.0 | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Build Helm Charts | ||
id: build_helm_charts | ||
run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}" | ||
|
||
- name: Upload Helm Chart as release asset | ||
env: | ||
RELEASE_TAG: ${{ needs.release.outputs.RELEASE_TAG }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release upload "$RELEASE_TAG" installer/*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: v2 | ||
name: argo-service | ||
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: "0.9.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "argo-service.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 "argo-service.fullname" . }}' | ||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "argo-service.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 "argo-service.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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "argo-service.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 "argo-service.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 "argo-service.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "argo-service.labels" -}} | ||
helm.sh/chart: {{ include "argo-service.chart" . }} | ||
{{ include "argo-service.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "argo-service.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "argo-service.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "argo-service.serviceAccountName" -}} | ||
keptn-argo-service | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "argo-service.fullname" . }} | ||
labels: | ||
{{- include "argo-service.labels" . | nindent 4 }} | ||
spec: | ||
{{- if not .Values.autoscaling.enabled }} | ||
replicas: {{ .Values.replicaCount }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
{{- include "argo-service.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
{{- with .Values.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
labels: | ||
{{- include "argo-service.labels" . | nindent 8 }} | ||
spec: | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
serviceAccountName: {{ include "argo-service.serviceAccountName" . }} | ||
securityContext: | ||
{{- toYaml .Values.podSecurityContext | nindent 8 }} | ||
containers: | ||
- name: argo-service | ||
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 | ||
resources: | ||
{{- toYaml .Values.resources | nindent 12 }} | ||
- name: distributor | ||
image: "{{ .Values.distributor.image.repository }}:{{ .Values.distributor.image.tag | default .Chart.AppVersion }}" | ||
livenessProbe: | ||
httpGet: | ||
path: /health | ||
port: 10999 | ||
initialDelaySeconds: 0 | ||
periodSeconds: 5 | ||
readinessProbe: | ||
httpGet: | ||
path: /health | ||
port: 10999 | ||
initialDelaySeconds: 5 | ||
periodSeconds: 5 | ||
imagePullPolicy: {{ .Values.distributor.image.pullPolicy }} | ||
ports: | ||
- containerPort: 8080 | ||
resources: | ||
requests: | ||
memory: "16Mi" | ||
cpu: "25m" | ||
limits: | ||
memory: "32Mi" | ||
cpu: "100m" | ||
env: | ||
- name: PUBSUB_URL | ||
value: 'nats://keptn-nats-cluster' | ||
- name: PUBSUB_TOPIC | ||
value: 'sh.keptn.event.release.triggered,sh.keptn.event.rollback.triggered,sh.keptn.event.test.triggered' | ||
- name: PUBSUB_RECIPIENT | ||
value: '127.0.0.1' | ||
- name: STAGE_FILTER | ||
value: "{{ .Values.distributor.stageFilter }}" | ||
- name: PROJECT_FILTER | ||
value: "{{ .Values.distributor.projectFilter }}" | ||
- name: SERVICE_FILTER | ||
value: "{{ .Values.distributor.serviceFilter }}" | ||
- name: VERSION | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.labels['app.kubernetes.io/version'] | ||
- name: LOCATION | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.labels['app.kubernetes.io/component'] | ||
- name: K8S_DEPLOYMENT_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.labels['app.kubernetes.io/name'] | ||
- name: K8S_POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: K8S_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: K8S_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
{{- if .Values.remoteControlPlane.enabled }} | ||
- name: KEPTN_API_ENDPOINT | ||
value: "{{ .Values.remoteControlPlane.api.protocol }}://{{ .Values.remoteControlPlane.api.hostname }}/api" | ||
- name: KEPTN_API_TOKEN | ||
value: "{{ .Values.remoteControlPlane.api.token }}" | ||
- name: HTTP_SSL_VERIFY | ||
{{- $apiValidateTls := .Values.remoteControlPlane.api.apiValidateTls | ternary "true" "false" }} | ||
value: "{{ $apiValidateTls }}" | ||
{{- end }} | ||
|
||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.affinity }} | ||
affinity: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} |
Oops, something went wrong.