Compare commits
42 Commits
bg-deploy-
...
master
Author | SHA1 | Date |
---|---|---|
Anand Francis Joseph | d7927a27b4 | |
May Zhang | 53e28ff20c | |
Ajay Kemparaj | 466269de45 | |
Alexander Matyushentsev | 08f72e2a30 | |
Alex Collins | 6bed858de3 | |
Alex Collins | 94ad32f4ea | |
jannfis | 5c2d89b897 | |
Alexander Matyushentsev | b4ebe0049d | |
Herrmann Hinz | 1ccdee0a61 | |
Alex Collins | 6150e82d92 | |
Omer Kahani | 08836bd970 | |
Liviu Costea | 454cc52962 | |
Alex Collins | 0ad95c51bc | |
Alexander Matyushentsev | 35ca7c333d | |
Alex Collins | e8fe3804f8 | |
Alex Collins | c77a1b2d15 | |
Alex Collins | 36363233d0 | |
Alexander Matyushentsev | 90ff6843e2 | |
Alexander Matyushentsev | 3f461c308f | |
Alexander Matyushentsev | fd70f16a43 | |
Alexander Matyushentsev | 826b3fa710 | |
Alex Collins | 3ef31aef9c | |
Alexander Matyushentsev | 23eeb0925b | |
Alex Collins | 179faabd63 | |
Alexander Matyushentsev | 8a1cb4a02d | |
Nick Johnson | 1ff8a67040 | |
Jesse Suen | 58594acf36 | |
Jesse Suen | 8c06d23268 | |
Jesse Suen | b0decab622 | |
Jesse Suen | 382b85852f | |
Jesse Suen | 62c453945b | |
Jesse Suen | d9c52b4c89 | |
Alexander Matyushentsev | c86a7fbb8e | |
Alexander Matyushentsev | 9c549b198c | |
Jesse Suen | a3ea618bb9 | |
Jesse Suen | 9421276024 | |
Jesse Suen | 5eb3352b40 | |
Jesse Suen | e3a5ac20fc | |
Jesse Suen | e0c05b3b14 | |
Jesse Suen | 144fd97a0c | |
Jesse Suen | 96a019c088 | |
Jesse Suen | b9eec94e60 |
20
README.md
20
README.md
|
@ -1 +1,21 @@
|
||||||
# ArgoCD Example Apps
|
# ArgoCD Example Apps
|
||||||
|
|
||||||
|
This repository contains example applications for demoing ArgoCD functionality. Feel free
|
||||||
|
to register this repository to your ArgoCD instance, or fork this repo and push your own commits
|
||||||
|
to explore ArgoCD and GitOps!
|
||||||
|
|
||||||
|
| Application | Description |
|
||||||
|
|-------------|-------------|
|
||||||
|
| [guestbook](guestbook/) | A hello word guestbook app as plain YAML |
|
||||||
|
| [ksonnet-guestbook](ksonnet-guestbook/) | The guestbook app as a ksonnet app |
|
||||||
|
| [helm-guestbook](helm-guestbook/) | The guestbook app as a Helm chart |
|
||||||
|
| [jsonnet-guestbook](jsonnet-guestbook/) | The guestbook app as a raw jsonnet |
|
||||||
|
| [jsonnet-guestbook-tla](jsonnet-guestbook-tla/) | The guestbook app as a raw jsonnet with support for top level arguments |
|
||||||
|
| [kustomize-guestbook](kustomize-guestbook/) | The guestbook app as a Kustomize 2 app |
|
||||||
|
| [pre-post-sync](pre-post-sync/) | Demonstrates Argo CD PreSync and PostSync hooks |
|
||||||
|
| [sync-waves](sync-waves/) | Demonstrates Argo CD sync waves with hooks |
|
||||||
|
| [helm-dependency](helm-dependency/) | Demonstrates how to customize an OTS (off-the-shelf) helm chart from an upstream repo |
|
||||||
|
| [sock-shop](sock-shop/) | A microservices demo app (https://microservices-demo.github.io) |
|
||||||
|
| [plugins](plugins/) | Apps which demonstrate config management plugins usage |
|
||||||
|
| [blue-green](blue-green/) | Demonstrates how to implement blue-green deployment using [Argo Rollouts](https://github.com/argoproj/argo-rollouts)
|
||||||
|
| [apps](apps/) | An app composed of other apps |
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
apiVersion: v2
|
||||||
|
name: applications
|
||||||
|
description: Applications
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
appVersion: "1.0"
|
|
@ -0,0 +1,16 @@
|
||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: helm-guestbook
|
||||||
|
namespace: argocd
|
||||||
|
finalizers:
|
||||||
|
- resources-finalizer.argocd.argoproj.io
|
||||||
|
spec:
|
||||||
|
destination:
|
||||||
|
namespace: helm-guestbook
|
||||||
|
server: {{ .Values.spec.destination.server }}
|
||||||
|
project: default
|
||||||
|
source:
|
||||||
|
path: helm-guestbook
|
||||||
|
repoURL: {{ .Values.spec.source.repoURL }}
|
||||||
|
targetRevision: {{ .Values.spec.source.targetRevision }}
|
|
@ -0,0 +1,17 @@
|
||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: helm-hooks
|
||||||
|
namespace: argocd
|
||||||
|
finalizers:
|
||||||
|
- resources-finalizer.argocd.argoproj.io
|
||||||
|
spec:
|
||||||
|
destination:
|
||||||
|
namespace: helm-hooks
|
||||||
|
server: {{ .Values.spec.destination.server }}
|
||||||
|
project: default
|
||||||
|
source:
|
||||||
|
path: helm-hooks
|
||||||
|
repoURL: {{ .Values.spec.source.repoURL }}
|
||||||
|
targetRevision: {{ .Values.spec.source.targetRevision }}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: kustomize-guestbook
|
||||||
|
namespace: argocd
|
||||||
|
finalizers:
|
||||||
|
- resources-finalizer.argocd.argoproj.io
|
||||||
|
spec:
|
||||||
|
destination:
|
||||||
|
namespace: kustomize-guestbook
|
||||||
|
server: {{ .Values.spec.destination.server }}
|
||||||
|
project: default
|
||||||
|
source:
|
||||||
|
path: kustomize-guestbook
|
||||||
|
repoURL: {{ .Values.spec.source.repoURL }}
|
||||||
|
targetRevision: {{ .Values.spec.source.targetRevision }}
|
|
@ -0,0 +1,27 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: helm-guestbook
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "-1"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: helm-hooks
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "-1"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: kustomize-guestbook
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "-1"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: sync-waves
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "-1"
|
|
@ -0,0 +1,16 @@
|
||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: sync-waves
|
||||||
|
namespace: argocd
|
||||||
|
finalizers:
|
||||||
|
- resources-finalizer.argocd.argoproj.io
|
||||||
|
spec:
|
||||||
|
destination:
|
||||||
|
namespace: sync-waves
|
||||||
|
server: {{ .Values.spec.destination.server }}
|
||||||
|
project: default
|
||||||
|
source:
|
||||||
|
path: sync-waves
|
||||||
|
repoURL: {{ .Values.spec.source.repoURL }}
|
||||||
|
targetRevision: {{ .Values.spec.source.targetRevision }}
|
|
@ -0,0 +1,6 @@
|
||||||
|
spec:
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
source:
|
||||||
|
repoURL: https://github.com/argoproj/argocd-example-apps
|
||||||
|
targetRevision: HEAD
|
|
@ -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
|
|
@ -0,0 +1,23 @@
|
||||||
|
apiVersion: v2
|
||||||
|
name: helm-guestbook
|
||||||
|
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.
|
||||||
|
appVersion: "1.0"
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Blue Green
|
||||||
|
|
||||||
|
The blue green strategy is not supported by built-in Kubernetes Deployment but available via third-party Kubernetes controller.
|
||||||
|
This example demonstrates how to implement blue-green deployment via [Argo Rollouts](https://github.com/argoproj/argo-rollouts):
|
||||||
|
|
||||||
|
1. Install Argo Rollouts controller: https://github.com/argoproj/argo-rollouts#installation
|
||||||
|
2. Create a sample application and sync it.
|
||||||
|
|
||||||
|
```
|
||||||
|
argocd app create --name blue-green --repo https://github.com/argoproj/argocd-example-apps --dest-server https://kubernetes.default.svc --dest-namespace default --path blue-green && argocd app sync blue-green
|
||||||
|
```
|
||||||
|
|
||||||
|
Once the application is synced you can access it using `blue-green-helm-guestbook` service.
|
||||||
|
|
||||||
|
3. Change image version parameter to trigger blue-green deployment process:
|
||||||
|
|
||||||
|
```
|
||||||
|
argocd app set blue-green -p image.tag=0.2 && argocd app sync blue-green
|
||||||
|
```
|
||||||
|
|
||||||
|
Now application runs `ks-guestbook-demo:0.1` and `ks-guestbook-demo:0.2` images simultaneously.
|
||||||
|
The `ks-guestbook-demo:0.2` is still considered `blue` available only via preview service `blue-green-helm-guestbook-preview`.
|
||||||
|
|
||||||
|
4. Promote `ks-guestbook-demo:0.2` to `green` by patching `Rollout` resource:
|
||||||
|
|
||||||
|
```
|
||||||
|
argocd app patch-resource blue-green --kind Rollout --resource-name blue-green-helm-guestbook --patch '{ "status": { "verifyingPreview": false } }' --patch-type 'application/merge-patch+json'
|
||||||
|
```
|
||||||
|
|
||||||
|
This promotes `ks-guestbook-demo:0.2` to `green` status and `Rollout` deletes old replica which runs `ks-guestbook-demo:0.1`.
|
|
@ -0,0 +1,19 @@
|
||||||
|
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 "helm-guestbook.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 "helm-guestbook.fullname" . }}'
|
||||||
|
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "helm-guestbook.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 "helm-guestbook.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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Expand the name of the chart.
|
||||||
|
*/}}
|
||||||
|
{{- define "helm-guestbook.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 "helm-guestbook.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 "helm-guestbook.chart" -}}
|
||||||
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
|
@ -0,0 +1,56 @@
|
||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Rollout
|
||||||
|
metadata:
|
||||||
|
name: {{ template "helm-guestbook.fullname" . }}
|
||||||
|
labels:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
chart: {{ template "helm-guestbook.chart" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
heritage: {{ .Release.Service }}
|
||||||
|
spec:
|
||||||
|
replicas: {{ .Values.replicaCount }}
|
||||||
|
revisionHistoryLimit: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
strategy:
|
||||||
|
blueGreen:
|
||||||
|
activeService: {{ template "helm-guestbook.fullname" . }}
|
||||||
|
previewService: {{ template "helm-guestbook.fullname" . }}-preview
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: {{ .Chart.Name }}
|
||||||
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 80
|
||||||
|
protocol: TCP
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: http
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: http
|
||||||
|
resources:
|
||||||
|
{{ toYaml .Values.resources | indent 12 }}
|
||||||
|
{{- with .Values.nodeSelector }}
|
||||||
|
nodeSelector:
|
||||||
|
{{ toYaml . | indent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.affinity }}
|
||||||
|
affinity:
|
||||||
|
{{ toYaml . | indent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.tolerations }}
|
||||||
|
tolerations:
|
||||||
|
{{ toYaml . | indent 8 }}
|
||||||
|
{{- end }}
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ template "helm-guestbook.fullname" . }}
|
||||||
|
labels:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
chart: {{ template "helm-guestbook.chart" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
heritage: {{ .Release.Service }}
|
||||||
|
spec:
|
||||||
|
type: {{ .Values.service.type }}
|
||||||
|
ports:
|
||||||
|
- port: {{ .Values.service.port }}
|
||||||
|
targetPort: http
|
||||||
|
protocol: TCP
|
||||||
|
name: http
|
||||||
|
selector:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ template "helm-guestbook.fullname" . }}-preview
|
||||||
|
labels:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
chart: {{ template "helm-guestbook.chart" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
heritage: {{ .Release.Service }}
|
||||||
|
spec:
|
||||||
|
type: {{ .Values.service.type }}
|
||||||
|
ports:
|
||||||
|
- port: {{ .Values.service.port }}
|
||||||
|
targetPort: http
|
||||||
|
protocol: TCP
|
||||||
|
name: http
|
||||||
|
selector:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
release: {{ .Release.Name }}
|
|
@ -0,0 +1,45 @@
|
||||||
|
# Default values for helm-guestbook.
|
||||||
|
# This is a YAML-formatted file.
|
||||||
|
# Declare variables to be passed into your templates.
|
||||||
|
|
||||||
|
replicaCount: 1
|
||||||
|
|
||||||
|
image:
|
||||||
|
repository: gcr.io/heptio-images/ks-guestbook-demo
|
||||||
|
tag: 0.1
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
service:
|
||||||
|
type: ClusterIP
|
||||||
|
port: 80
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
enabled: false
|
||||||
|
annotations: {}
|
||||||
|
# kubernetes.io/ingress.class: nginx
|
||||||
|
# kubernetes.io/tls-acme: "true"
|
||||||
|
path: /
|
||||||
|
hosts:
|
||||||
|
- chart-example.local
|
||||||
|
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: {}
|
|
@ -1,11 +0,0 @@
|
||||||
apiVersion: 0.1.0
|
|
||||||
environments:
|
|
||||||
default:
|
|
||||||
destination:
|
|
||||||
namespace: default
|
|
||||||
server: https://kubernetes.default.svc
|
|
||||||
k8sVersion: v1.10.0
|
|
||||||
path: default
|
|
||||||
kind: ksonnet.io/app
|
|
||||||
name: guestbook
|
|
||||||
version: 0.0.1
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: guestbook-ui
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
revisionHistoryLimit: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: guestbook-ui
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: guestbook-ui
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: gcr.io/heptio-images/ks-guestbook-demo:0.2
|
||||||
|
name: guestbook-ui
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
|
@ -0,0 +1,10 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: guestbook-ui
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 80
|
||||||
|
selector:
|
||||||
|
app: guestbook-ui
|
|
@ -0,0 +1,28 @@
|
||||||
|
apiVersion: v2
|
||||||
|
name: wordpress
|
||||||
|
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.
|
||||||
|
appVersion: "1.0"
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- name: wordpress
|
||||||
|
version: 9.0.3
|
||||||
|
repository: https://charts.helm.sh/stable
|
|
@ -0,0 +1,55 @@
|
||||||
|
# Helm Dependencies
|
||||||
|
|
||||||
|
This example application demonstrates how an OTS (off-the-shelf) helm chart can be retrieved and
|
||||||
|
pinned to a specific helm sem version from an upstream helm repository, and customized using a custom
|
||||||
|
values.yaml in the private git repository.
|
||||||
|
|
||||||
|
In this example, the wordpress application is pulled from the stable helm repo, and pinned to v5.0.2:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
dependencies:
|
||||||
|
- name: wordpress
|
||||||
|
version: 5.0.2
|
||||||
|
repository: https://charts.helm.sh/stable
|
||||||
|
```
|
||||||
|
|
||||||
|
A custom values.yaml is used to customize the parameters of the wordpress helm chart:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
wordpress:
|
||||||
|
wordpressPassword: foo
|
||||||
|
mariadb:
|
||||||
|
db:
|
||||||
|
password: bar
|
||||||
|
rootUser:
|
||||||
|
password: baz
|
||||||
|
```
|
||||||
|
|
||||||
|
### Subchart Note
|
||||||
|
|
||||||
|
The wordpress chart referenced in this example contains a subchart for mariadb as specified in the requirements.yaml file of the wordpress chart:
|
||||||
|
```yaml
|
||||||
|
- name: mariadb
|
||||||
|
version: 5.x.x
|
||||||
|
repository: https://charts.helm.sh/stable
|
||||||
|
condition: mariadb.enabled
|
||||||
|
tags:
|
||||||
|
- wordpress-database
|
||||||
|
```
|
||||||
|
|
||||||
|
In order to disable this chart, you must set the value to false for both `mariadb.enabled` and `wordpress.mariadb.enabled`. The first is used by the mariadb subchart condition field, the second is used by the wordpress chart deployment template. An example demonstration is available in the values-nomaria.yaml file:
|
||||||
|
```yaml
|
||||||
|
mariadb:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
wordpress:
|
||||||
|
wordpressPassword: foo
|
||||||
|
mariadb:
|
||||||
|
enabled: false
|
||||||
|
externalDatabase:
|
||||||
|
host: localhost
|
||||||
|
user: bn_wordpress
|
||||||
|
password: ""
|
||||||
|
database: bitnami_wordpress
|
||||||
|
port: 3306
|
||||||
|
```
|
|
@ -0,0 +1,13 @@
|
||||||
|
mariadb:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
wordpress:
|
||||||
|
wordpressPassword: foo
|
||||||
|
mariadb:
|
||||||
|
enabled: false
|
||||||
|
externalDatabase:
|
||||||
|
host: localhost
|
||||||
|
user: bn_wordpress
|
||||||
|
password: ""
|
||||||
|
database: bitnami_wordpress
|
||||||
|
port: 3306
|
|
@ -0,0 +1,7 @@
|
||||||
|
wordpress:
|
||||||
|
wordpressPassword: foo
|
||||||
|
mariadb:
|
||||||
|
db:
|
||||||
|
password: bar
|
||||||
|
rootUser:
|
||||||
|
password: baz
|
|
@ -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
|
|
@ -0,0 +1,23 @@
|
||||||
|
apiVersion: v2
|
||||||
|
name: helm-guestbook
|
||||||
|
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.
|
||||||
|
appVersion: "1.0"
|
|
@ -0,0 +1,19 @@
|
||||||
|
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 "helm-guestbook.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 "helm-guestbook.fullname" . }}'
|
||||||
|
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "helm-guestbook.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 "helm-guestbook.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 }}
|
|
@ -0,0 +1,32 @@
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Expand the name of the chart.
|
||||||
|
*/}}
|
||||||
|
{{- define "helm-guestbook.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 "helm-guestbook.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 "helm-guestbook.chart" -}}
|
||||||
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
|
@ -0,0 +1,52 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: {{ template "helm-guestbook.fullname" . }}
|
||||||
|
labels:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
chart: {{ template "helm-guestbook.chart" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
heritage: {{ .Release.Service }}
|
||||||
|
spec:
|
||||||
|
replicas: {{ .Values.replicaCount }}
|
||||||
|
revisionHistoryLimit: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: {{ .Chart.Name }}
|
||||||
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: {{ .Values.containerPort }}
|
||||||
|
protocol: TCP
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: http
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: http
|
||||||
|
resources:
|
||||||
|
{{ toYaml .Values.resources | indent 12 }}
|
||||||
|
{{- with .Values.nodeSelector }}
|
||||||
|
nodeSelector:
|
||||||
|
{{ toYaml . | indent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.affinity }}
|
||||||
|
affinity:
|
||||||
|
{{ toYaml . | indent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.tolerations }}
|
||||||
|
tolerations:
|
||||||
|
{{ toYaml . | indent 8 }}
|
||||||
|
{{- end }}
|
|
@ -0,0 +1,19 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ template "helm-guestbook.fullname" . }}
|
||||||
|
labels:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
chart: {{ template "helm-guestbook.chart" . }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
heritage: {{ .Release.Service }}
|
||||||
|
spec:
|
||||||
|
type: {{ .Values.service.type }}
|
||||||
|
ports:
|
||||||
|
- port: {{ .Values.service.port }}
|
||||||
|
targetPort: http
|
||||||
|
protocol: TCP
|
||||||
|
name: http
|
||||||
|
selector:
|
||||||
|
app: {{ template "helm-guestbook.name" . }}
|
||||||
|
release: {{ .Release.Name }}
|
|
@ -0,0 +1,2 @@
|
||||||
|
service:
|
||||||
|
type: LoadBalancer
|
|
@ -0,0 +1,47 @@
|
||||||
|
# Default values for helm-guestbook.
|
||||||
|
# This is a YAML-formatted file.
|
||||||
|
# Declare variables to be passed into your templates.
|
||||||
|
|
||||||
|
replicaCount: 1
|
||||||
|
|
||||||
|
image:
|
||||||
|
repository: gcr.io/heptio-images/ks-guestbook-demo
|
||||||
|
tag: 0.1
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
containerPort: 80
|
||||||
|
|
||||||
|
service:
|
||||||
|
type: ClusterIP
|
||||||
|
port: 80
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
enabled: false
|
||||||
|
annotations: {}
|
||||||
|
# kubernetes.io/ingress.class: nginx
|
||||||
|
# kubernetes.io/tls-acme: "true"
|
||||||
|
path: /
|
||||||
|
hosts:
|
||||||
|
- chart-example.local
|
||||||
|
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: {}
|
|
@ -0,0 +1,82 @@
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
generateName: upgrade-sql-schema
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: pre-install
|
||||||
|
helm.sh/hook-weight: "-2"
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: upgrade-sql-schema
|
||||||
|
image: alpine:latest
|
||||||
|
command: ["sleep", "5"]
|
||||||
|
restartPolicy: Never
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: maint-page-up
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: pre-install
|
||||||
|
helm.sh/hook-delete-policy: before-hook-creation
|
||||||
|
helm.sh/hook-weight: "-1"
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: page-up
|
||||||
|
image: alpine:latest
|
||||||
|
command: ["sleep", "2"]
|
||||||
|
restartPolicy: Never
|
||||||
|
backoffLimit: 0
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: ReplicaSet
|
||||||
|
metadata:
|
||||||
|
name: frontend
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
tier: frontend
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
tier: frontend
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: main
|
||||||
|
image: nginx:latest
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: frontend
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook-weight: "2"
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
tier: frontend
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 80
|
||||||
|
targetPort: 80
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: maint-page-down
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: post-install
|
||||||
|
helm.sh/hook-delete-policy: before-hook-creation
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: page-down
|
||||||
|
image: alpine:latest
|
||||||
|
command: ["sleep", "2"]
|
||||||
|
restartPolicy: Never
|
|
@ -0,0 +1,65 @@
|
||||||
|
function (
|
||||||
|
containerPort=80,
|
||||||
|
image="gcr.io/heptio-images/ks-guestbook-demo:0.2",
|
||||||
|
name="jsonnet-guestbook-ui",
|
||||||
|
replicas=1,
|
||||||
|
servicePort=80,
|
||||||
|
type="LoadBalancer"
|
||||||
|
)
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"kind": "Service",
|
||||||
|
"metadata": {
|
||||||
|
"name": name
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"port": servicePort,
|
||||||
|
"targetPort": containerPort
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"selector": {
|
||||||
|
"app": name
|
||||||
|
},
|
||||||
|
"type": type
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"apiVersion": "apps/v1",
|
||||||
|
"kind": "Deployment",
|
||||||
|
"metadata": {
|
||||||
|
"name": name
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"replicas": replicas,
|
||||||
|
"revisionHistoryLimit": 3,
|
||||||
|
"selector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"app": name
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"metadata": {
|
||||||
|
"labels": {
|
||||||
|
"app": name
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"image": image,
|
||||||
|
"name": name,
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"containerPort": containerPort
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1,59 @@
|
||||||
|
local params = import 'params.libsonnet';
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"apiVersion": "v1",
|
||||||
|
"kind": "Service",
|
||||||
|
"metadata": {
|
||||||
|
"name": params.name
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"port": params.servicePort,
|
||||||
|
"targetPort": params.containerPort
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"selector": {
|
||||||
|
"app": params.name
|
||||||
|
},
|
||||||
|
"type": params.type
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"apiVersion": "apps/v1",
|
||||||
|
"kind": "Deployment",
|
||||||
|
"metadata": {
|
||||||
|
"name": params.name
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"replicas": params.replicas,
|
||||||
|
"revisionHistoryLimit": 3,
|
||||||
|
"selector": {
|
||||||
|
"matchLabels": {
|
||||||
|
"app": params.name
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"template": {
|
||||||
|
"metadata": {
|
||||||
|
"labels": {
|
||||||
|
"app": params.name
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [
|
||||||
|
{
|
||||||
|
"image": params.image,
|
||||||
|
"name": params.name,
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"containerPort": params.containerPort
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
containerPort: 80,
|
||||||
|
image: "gcr.io/heptio-images/ks-guestbook-demo:0.2",
|
||||||
|
name: "jsonnet-guestbook-ui",
|
||||||
|
replicas: 1,
|
||||||
|
servicePort: 80,
|
||||||
|
type: "LoadBalancer",
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
apiVersion: 0.1.0
|
||||||
|
environments:
|
||||||
|
default:
|
||||||
|
destination:
|
||||||
|
namespace: default
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
k8sVersion: v1.10.0
|
||||||
|
path: default
|
||||||
|
dev:
|
||||||
|
destination:
|
||||||
|
namespace: dev
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
k8sVersion: v1.10.0
|
||||||
|
path: dev
|
||||||
|
prod:
|
||||||
|
destination:
|
||||||
|
namespace: prod
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
k8sVersion: v1.10.0
|
||||||
|
path: prod
|
||||||
|
kind: ksonnet.io/app
|
||||||
|
name: guestbook
|
||||||
|
version: 0.0.1
|
|
@ -21,13 +21,14 @@ local params = std.extVar("__ksonnet/params").components["guestbook-ui"];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"apiVersion": "apps/v1beta2",
|
"apiVersion": "apps/v1",
|
||||||
"kind": "Deployment",
|
"kind": "Deployment",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": params.name
|
"name": params.name
|
||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"replicas": params.replicas,
|
"replicas": params.replicas,
|
||||||
|
"revisionHistoryLimit": 3,
|
||||||
"selector": {
|
"selector": {
|
||||||
"matchLabels": {
|
"matchLabels": {
|
||||||
"app": params.name
|
"app": params.name
|
|
@ -9,7 +9,7 @@
|
||||||
"guestbook-ui": {
|
"guestbook-ui": {
|
||||||
containerPort: 80,
|
containerPort: 80,
|
||||||
image: "gcr.io/heptio-images/ks-guestbook-demo:0.2",
|
image: "gcr.io/heptio-images/ks-guestbook-demo:0.2",
|
||||||
name: "guestbook-ui",
|
name: "ks-guestbook-ui",
|
||||||
replicas: 1,
|
replicas: 1,
|
||||||
servicePort: 80,
|
servicePort: 80,
|
||||||
type: "LoadBalancer",
|
type: "LoadBalancer",
|
|
@ -0,0 +1,2 @@
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
local base = import "base.libsonnet";
|
||||||
|
// uncomment if you reference ksonnet-lib
|
||||||
|
// local k = import "k.libsonnet";
|
||||||
|
|
||||||
|
base + {
|
||||||
|
// Insert user-specified overrides here. For example if a component is named \"nginx-deployment\", you might have something like:\n")
|
||||||
|
// "nginx-deployment"+: k.deployment.mixin.metadata.labels({foo: "bar"})
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
local params = std.extVar("__ksonnet/params");
|
||||||
|
local globals = import "globals.libsonnet";
|
||||||
|
local envParams = params + {
|
||||||
|
components +: {
|
||||||
|
// Insert component parameter overrides here. Ex:
|
||||||
|
// guestbook +: {
|
||||||
|
// name: "guestbook-dev",
|
||||||
|
// replicas: params.global.replicas,
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
components: {
|
||||||
|
[x]: envParams.components[x] + globals, for x in std.objectFields(envParams.components)
|
||||||
|
},
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: guestbook-ui
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
revisionHistoryLimit: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: guestbook-ui
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: guestbook-ui
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: gcr.io/heptio-images/ks-guestbook-demo:0.1
|
||||||
|
name: guestbook-ui
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
|
@ -0,0 +1,10 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: guestbook-ui
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 80
|
||||||
|
selector:
|
||||||
|
app: guestbook-ui
|
|
@ -0,0 +1,7 @@
|
||||||
|
namePrefix: kustomize-
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- guestbook-ui-deployment.yaml
|
||||||
|
- guestbook-ui-svc.yaml
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Config Management Plugins Examples
|
||||||
|
|
||||||
|
| Application | Description |
|
||||||
|
|-------------|-------------|
|
||||||
|
| [kasane](kasane/) | The guestbook application as a `kasane` package. |
|
||||||
|
| [kustomized-helm](kustomized-helm/) | Application comprised of a `helm` chart and customized using `kustomize` |
|
|
@ -0,0 +1,2 @@
|
||||||
|
vendor
|
||||||
|
Kasanefile.lock
|
|
@ -0,0 +1,5 @@
|
||||||
|
layers:
|
||||||
|
- ../../guestbook/guestbook-ui-deployment.yaml
|
||||||
|
- patch.jsonnet
|
||||||
|
- ../../guestbook/guestbook-ui-svc.yaml
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Kasane
|
||||||
|
|
||||||
|
[Kasane](https://github.com/google/kasane) is a layering tool for Kubernetes which utilises Jsonnet for deep object modification and patching.
|
||||||
|
|
||||||
|
Use following steps to try the application:
|
||||||
|
|
||||||
|
* Follow instructions from [custom_tools.md](https://github.com/argoproj/argo-cd/blob/master/docs/operator-manual/custom_tools.md) to make sure `kasane` binary is available in `argocd-repo-server` pod.
|
||||||
|
* Register `kasane` plugin `argocd-cm` ConfigMap:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
configManagementPlugins: |
|
||||||
|
- name: kasane
|
||||||
|
init:
|
||||||
|
command: [kasane, update]
|
||||||
|
generate:
|
||||||
|
command: [kasane, show]
|
||||||
|
```
|
||||||
|
* Create application using `kasane` as a config management plugin name.
|
||||||
|
|
||||||
|
```
|
||||||
|
argocd app create kasane \
|
||||||
|
--config-management-plugin kasane \
|
||||||
|
--repo https://github.com/argoproj/argocd-example-apps \
|
||||||
|
--path plugins/kasane \
|
||||||
|
--dest-server https://kubernetes.default.svc \
|
||||||
|
--dest-namespace default
|
||||||
|
```
|
|
@ -0,0 +1,9 @@
|
||||||
|
function (layers)
|
||||||
|
|
||||||
|
[
|
||||||
|
layers[0] {
|
||||||
|
spec+: {
|
||||||
|
replicas: 2,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]
|
|
@ -0,0 +1,3 @@
|
||||||
|
all.yaml
|
||||||
|
charts
|
||||||
|
requirements.lock
|
|
@ -0,0 +1,28 @@
|
||||||
|
apiVersion: v2
|
||||||
|
name: guestbook
|
||||||
|
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.
|
||||||
|
appVersion: "1.0"
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- name: helm-guestbook
|
||||||
|
version: 0.1.0
|
||||||
|
repository: file://../../helm-guestbook
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Helm + Kustomize
|
||||||
|
|
||||||
|
Sometimes Helm chart don't have all required parameters and additional customization is required. This example application demonstrates how to combine Helm and Kustomize and use it
|
||||||
|
as a config management plugin in Argo CD.
|
||||||
|
|
||||||
|
Use following steps to try the application:
|
||||||
|
|
||||||
|
* configure `kustomized-helm` tool in `argocd-cm` ConfigMap:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
configManagementPlugins: |
|
||||||
|
- name: kustomized-helm
|
||||||
|
init:
|
||||||
|
command: ["/bin/sh", "-c"]
|
||||||
|
args: ["helm dependency build"]
|
||||||
|
generate:
|
||||||
|
command: [sh, -c]
|
||||||
|
args: ["helm template --release-name release-name . > all.yaml && kustomize build"]
|
||||||
|
```
|
||||||
|
|
||||||
|
* create application using `kustomized-helm` as a config management plugin name:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
argocd app create kustomized-helm \
|
||||||
|
--config-management-plugin kustomized-helm \
|
||||||
|
--repo https://github.com/argoproj/argocd-example-apps \
|
||||||
|
--path plugins/kustomized-helm \
|
||||||
|
--dest-server https://kubernetes.default.svc \
|
||||||
|
--dest-namespace default
|
||||||
|
```
|
|
@ -0,0 +1,7 @@
|
||||||
|
namePrefix: kustomize-
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- ./all.yaml
|
||||||
|
|
||||||
|
patches:
|
||||||
|
- overlays/guestbook-deployment.yaml
|
|
@ -0,0 +1,10 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: release-name-helm-guestbook
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: helm-guestbook
|
||||||
|
image: "gcr.io/heptio-images/ks-guestbook-demo:0.2"
|
|
@ -0,0 +1,8 @@
|
||||||
|
namePrefix: pre-post-sync-
|
||||||
|
|
||||||
|
bases:
|
||||||
|
- ../kustomize-guestbook
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- pre-sync-job.yaml
|
||||||
|
- post-sync-job.yaml
|
|
@ -0,0 +1,16 @@
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: after
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/hook: PostSync
|
||||||
|
argocd.argoproj.io/hook-delete-policy: HookSucceeded
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: sleep
|
||||||
|
image: alpine:latest
|
||||||
|
command: ["sleep", "10"]
|
||||||
|
restartPolicy: Never
|
||||||
|
backoffLimit: 0
|
|
@ -0,0 +1,16 @@
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: before
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/hook: PreSync
|
||||||
|
argocd.argoproj.io/hook-delete-policy: HookSucceeded
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: sleep
|
||||||
|
image: alpine:latest
|
||||||
|
command: ["sleep", "10"]
|
||||||
|
restartPolicy: Never
|
||||||
|
backoffLimit: 0
|
|
@ -1,4 +0,0 @@
|
||||||
/lib
|
|
||||||
/.ksonnet/registries
|
|
||||||
/app.override.yaml
|
|
||||||
/.ks_environment
|
|
|
@ -1,11 +0,0 @@
|
||||||
apiVersion: 0.1.0
|
|
||||||
environments:
|
|
||||||
default:
|
|
||||||
destination:
|
|
||||||
namespace: default
|
|
||||||
server: https://kubernetes.default.svc
|
|
||||||
k8sVersion: v1.10.0
|
|
||||||
path: default
|
|
||||||
kind: ksonnet.io/app
|
|
||||||
name: sock-shop
|
|
||||||
version: 0.0.1
|
|
|
@ -1,37 +0,0 @@
|
||||||
{
|
|
||||||
global: {
|
|
||||||
// User-defined global parameters; accessible to all component and environments, Ex:
|
|
||||||
// replicas: 4,
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
// Component-level parameters, defined initially from 'ks prototype use ...'
|
|
||||||
// Each object below should correspond to a component in the components/ directory
|
|
||||||
"carts-db-dep": {},
|
|
||||||
"carts-db-svc": {},
|
|
||||||
"carts-dep": {},
|
|
||||||
"catalogue-db-dep": {},
|
|
||||||
"catalogue-db-svc": {},
|
|
||||||
"catalogue-dep": {},
|
|
||||||
"catalogue-svc": {},
|
|
||||||
"front-end-dep": {},
|
|
||||||
"front-end-svc": {},
|
|
||||||
"orders-db-dep": {},
|
|
||||||
"orders-db-svc": {},
|
|
||||||
"orders-dep": {},
|
|
||||||
"orders-svc": {},
|
|
||||||
"payment-dep": {},
|
|
||||||
"payment-svc": {},
|
|
||||||
"queue-master-dep": {},
|
|
||||||
"queue-master-svc": {},
|
|
||||||
"rabbitmq-dep": {},
|
|
||||||
"rabbitmq-svc": {},
|
|
||||||
"session-db-dep": {},
|
|
||||||
"session-db-svc": {},
|
|
||||||
"shipping-dep": {},
|
|
||||||
"shipping-svc": {},
|
|
||||||
"user-db-dep": {},
|
|
||||||
"user-db-svc": {},
|
|
||||||
"user-dep": {},
|
|
||||||
"user-svc": {},
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
local components = std.extVar("__ksonnet/components");
|
|
||||||
components + {
|
|
||||||
// Insert user-specified overrides here.
|
|
||||||
}
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
resources:
|
||||||
|
- base/carts-db-dep.yaml
|
||||||
|
- base/carts-db-svc.yaml
|
||||||
|
- base/carts-dep.yaml
|
||||||
|
- base/catalogue-db-dep.yaml
|
||||||
|
- base/catalogue-db-svc.yaml
|
||||||
|
- base/catalogue-dep.yaml
|
||||||
|
- base/catalogue-svc.yaml
|
||||||
|
- base/front-end-dep.yaml
|
||||||
|
- base/front-end-svc.yaml
|
||||||
|
- base/orders-db-dep.yaml
|
||||||
|
- base/orders-db-svc.yaml
|
||||||
|
- base/orders-dep.yaml
|
||||||
|
- base/orders-svc.yaml
|
||||||
|
- base/payment-dep.yaml
|
||||||
|
- base/payment-svc.yaml
|
||||||
|
- base/queue-master-dep.yaml
|
||||||
|
- base/queue-master-svc.yaml
|
||||||
|
- base/rabbitmq-dep.yaml
|
||||||
|
- base/rabbitmq-svc.yaml
|
||||||
|
- base/session-db-dep.yaml
|
||||||
|
- base/session-db-svc.yaml
|
||||||
|
- base/shipping-dep.yaml
|
||||||
|
- base/shipping-svc.yaml
|
||||||
|
- base/user-db-dep.yaml
|
||||||
|
- base/user-db-svc.yaml
|
||||||
|
- base/user-dep.yaml
|
||||||
|
- base/user-svc.yaml
|
|
@ -0,0 +1,114 @@
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
generateName: upgrade-sql-schema
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/hook: PreSync
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: upgrade-sql-schema
|
||||||
|
image: alpine:latest
|
||||||
|
command: ["sleep", "5"]
|
||||||
|
restartPolicy: Never
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: ReplicaSet
|
||||||
|
metadata:
|
||||||
|
name: backend
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
tier: backend
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
tier: backend
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: main
|
||||||
|
image: nginx:latest
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: backend
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
tier: backend
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 8080
|
||||||
|
targetPort: 8080
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: maint-page-up
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/hook: Sync
|
||||||
|
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
|
||||||
|
argocd.argoproj.io/sync-wave: "1"
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: page-up
|
||||||
|
image: alpine:latest
|
||||||
|
command: ["sleep", "2"]
|
||||||
|
restartPolicy: Never
|
||||||
|
backoffLimit: 0
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: ReplicaSet
|
||||||
|
metadata:
|
||||||
|
name: frontend
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "2"
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
tier: frontend
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
tier: frontend
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: main
|
||||||
|
image: nginx:latest
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: frontend
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "2"
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
tier: frontend
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: 80
|
||||||
|
targetPort: 80
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: maint-page-down
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/hook: Sync
|
||||||
|
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
|
||||||
|
argocd.argoproj.io/sync-wave: "3"
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: page-down
|
||||||
|
image: alpine:latest
|
||||||
|
command: ["sleep", "2"]
|
||||||
|
restartPolicy: Never
|
Loading…
Reference in New Issue