Last active
March 3, 2022 12:03
-
-
Save MartinLuksik/14138354105c767934983660f2543263 to your computer and use it in GitHub Desktop.
[Helm] Helm #helm
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
## locate installed helm charts in a namespace: | |
helm list | |
## add new local repo | |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts | |
helm repo update | |
## get available chart versions | |
# helm search repo <reponame>/<chartname> --versions | |
helm search repo prometheus-community/kube-prometheus-stack --versions | |
## dry run: | |
helm upgrade --dry-run \ | |
--namespace abc \ | |
--values ./pipelines/deploy/helm-test.yaml \ | |
--values ./pipelines/deploy/myapp/app-values.yaml \ | |
my-chart-name helm/job | |
## upgrade or install | |
helm upgrade --install \ | |
--namespace abc \ | |
--values ./pipelines/deploy/helm-test.yaml \ | |
--values ./pipelines/deploy/myapp/app-values.yaml \ | |
my-chart-name helm/job | |
## template charts locally | |
helm template \ | |
--values ./pipelines/deploy/helm-test.yaml \ | |
--values ./pipelines/deploy/myapp/app-values.yaml \ | |
my-chart-name helm/job | |
## set var on install: | |
helm template \ | |
--values ./pipelines/deploy/helm-test.yaml \ | |
--values ./pipelines/deploy/myapp/app-values.yaml \ | |
--set image.tage=v0.1 \ | |
my-chart-name helm/job |
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
# Dockerfile | |
FROM bash:4.4 | |
RUN apk add --update curl | |
COPY healthCheck.sh / | |
CMD ["bash", "/healthCheck.sh"] | |
# healthCheck.sh | |
echo "$DOMAIN" | |
sleep 30 | |
RESPONSE=$(curl --write-out '%{http_code}' --silent --output /dev/null $DOMAIN) | |
echo "$RESPONSE" | |
if [ $RESPONSE == "200" ]; then | |
echo "It is all healthy!" | |
exit 0 | |
else | |
echo "Something is wrong here!" | |
exit 1 | |
fi | |
# /helm/templates/test/test.yaml | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: "{{ .Release.Name }}-test" | |
annotations: | |
"helm.sh/hook": test | |
spec: | |
containers: | |
- name: {{ .Release.Name }}-test | |
image: {{ .Values.helmtest.repository }} | |
imagePullPolicy: Always | |
env: | |
- name: DOMAIN | |
value: http://{{ .Values.svc.name }}/health | |
restartPolicy: Never | |
helm test --namespace myns myhelmrelease | |
# rollback on failure | |
helm rollback --namespace myns myhelmrelease | |
## pip reference: | |
stages: | |
- stage: ${{ parameters.environment }}_Apps_Deployments | |
variables: | |
- group: ${{ parameters.varGroupName }} | |
displayName: ${{ parameters.environment }}_Apps_Deployments | |
jobs: | |
- deployment: ${{ parameters.environment }}_Apps_Deployments | |
displayName: ${{ parameters.environment }}_Apps_Deployments | |
pool: ${{ parameters.agentPool }} | |
environment: ${{ parameters.devopsEnvironment }} | |
dependsOn: ${{ parameters.environment }}_SQL_Script | |
condition: succeeded() | |
strategy: | |
runOnce: | |
deploy: | |
steps: | |
- checkout: self | |
path: reporting | |
- task: Kubernetes@1 | |
inputs: | |
connectionType: 'Kubernetes Service Connection' | |
command: 'login' | |
versionSpec: ${{ parameters.k8sVersion }} | |
- task: Bash@3 | |
displayName: 'Deploy Apps via helm' | |
inputs: | |
workingDirectory: "$(Agent.BuildDirectory)/reporting/helm" | |
targetType: 'inline' | |
script: | | |
helm upgrade --install --namespace ${{ parameters.namespace }} \ | |
-f values.yaml \ | |
-f ${{ parameters.helmValues }} \ | |
--set dockerBuildTag=$(Build.SourceBranchName)-$(Build.BuildId) \ | |
--timeout 5m --wait \ | |
reportingjobserver . | |
- task: Bash@3 | |
displayName: 'Test Helm Chart' | |
inputs: | |
workingDirectory: "$(Agent.BuildDirectory)/reporting/helm" | |
targetType: 'inline' | |
script: | | |
helm test --namespace ${{ parameters.namespace }} reportingjobserver | |
on: | |
failure: | |
pool: ${{ parameters.agentPool }} | |
steps: | |
- checkout: self | |
path: reporting | |
- task: Kubernetes@1 | |
inputs: | |
connectionType: 'Kubernetes Service Connection' | |
command: 'login' | |
versionSpec: ${{ parameters.k8sVersion }} | |
- task: Bash@3 | |
displayName: 'Rollback on failed test' | |
inputs: | |
workingDirectory: "$(Agent.BuildDirectory)/reporting/helm" | |
targetType: 'inline' | |
script: | | |
helm rollback --namespace ${{ parameters.namespace }} reportingjobserver |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment