-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
230 additions
and
12 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
17 changes: 17 additions & 0 deletions
17
12-deploying-to-multiple-environments/kluctl-single-service/.kluctl.yaml
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,17 @@ | ||
targets: | ||
- name: staging | ||
args: | ||
environment: staging | ||
# Adding a context to .kluctl.yaml helps prevent accidentally deploying to the wrong cluster! | ||
context: devops-directive-kubernetes-course | ||
|
||
- name: production | ||
args: | ||
environment: production | ||
# Adding a context to .kluctl.yaml helps prevent accidentally deploying to the wrong cluster! | ||
context: gke_kubernetes-course-424917_us-central1-a_devops-directive-kubernetes-course | ||
|
||
args: | ||
- name: environment | ||
|
||
discriminator: kluctl-{{ target.name }} |
Empty file.
37 changes: 37 additions & 0 deletions
37
12-deploying-to-multiple-environments/kluctl-single-service/Taskfile.yaml
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,37 @@ | ||
version: "3" | ||
|
||
tasks: | ||
helm-pull: | ||
cmds: | ||
- kluctl helm-pull | ||
desc: "Pre-pull helm charts" | ||
|
||
render-staging: | ||
cmds: | ||
- kluctl render -t staging --print-all | yq | ||
desc: "Render resource yaml with staging values" | ||
|
||
deploy-staging: | ||
cmds: | ||
- kluctl deploy -t staging | ||
desc: "Deploy staging configuration" | ||
|
||
delete-staging: | ||
cmds: | ||
- kluctl delete -t staging | ||
desc: "Render resource yaml with staging values" | ||
|
||
render-production: | ||
cmds: | ||
- kluctl render -t production --print-all | yq | ||
desc: "Render resource yaml with production values" | ||
|
||
deploy-production: | ||
cmds: | ||
- kluctl deploy -t production | ||
desc: "Deploy production configuration" | ||
|
||
delete-production: | ||
cmds: | ||
- kluctl delete -t production | ||
desc: "Render resource yaml with production values" |
2 changes: 2 additions & 0 deletions
2
12-deploying-to-multiple-environments/kluctl-single-service/config/production.yaml
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,2 @@ | ||
sharedVars: | ||
hostName: "kubernetes-course.devopsdirective.com" |
2 changes: 2 additions & 0 deletions
2
12-deploying-to-multiple-environments/kluctl-single-service/config/staging.yaml
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,2 @@ | ||
sharedVars: | ||
hostName: "kubernetes-course-staging.devopsdirective.com" |
10 changes: 10 additions & 0 deletions
10
12-deploying-to-multiple-environments/kluctl-single-service/deployment.yaml
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,10 @@ | ||
vars: | ||
- file: config/{{ args.environment }}.yaml | ||
|
||
deployments: | ||
- path: namespaces | ||
- barrier: true | ||
- include: services | ||
|
||
commonLabels: | ||
devopsdirective.com/course: "kubernetes-course" |
4 changes: 4 additions & 0 deletions
4
...ploying-to-multiple-environments/kluctl-single-service/namespaces/Namespace.demo-app.yaml
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,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: demo-app |
3 changes: 3 additions & 0 deletions
3
...to-multiple-environments/kluctl-single-service/services/api-golang/config/production.yaml
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,3 @@ | ||
apiGolang: | ||
version: 0.3.0 # PRODUCTION_IMAGE_TAG | ||
replicas: 2 |
3 changes: 3 additions & 0 deletions
3
...ng-to-multiple-environments/kluctl-single-service/services/api-golang/config/staging.yaml
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,3 @@ | ||
apiGolang: | ||
version: 0.3.0-2-g29b7fb5 # STAGING_IMAGE_TAG | ||
replicas: 1 |
5 changes: 5 additions & 0 deletions
5
...loying-to-multiple-environments/kluctl-single-service/services/api-golang/deployment.yaml
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,5 @@ | ||
vars: | ||
- file: config/{{ args.environment }}.yaml | ||
|
||
deployments: | ||
- path: manifests |
45 changes: 45 additions & 0 deletions
45
...multiple-environments/kluctl-single-service/services/api-golang/manifests/Deployment.yaml
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,45 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: api-golang | ||
namespace: demo-app | ||
labels: | ||
app: api-golang | ||
spec: | ||
replicas: {{apiGolang.replicas}} | ||
selector: | ||
matchLabels: | ||
app: api-golang | ||
template: | ||
metadata: | ||
labels: | ||
app: api-golang | ||
spec: | ||
containers: | ||
- name: api-golang | ||
image: sidpalas/devops-directive-docker-course-api-golang:{{ apiGolang.version }} | ||
env: | ||
- name: PORT | ||
value: "8000" | ||
envFrom: | ||
- secretRef: | ||
name: api-golang-database-url | ||
ports: | ||
- containerPort: 8000 | ||
protocol: TCP | ||
readinessProbe: | ||
httpGet: | ||
path: /ping | ||
port: 8000 | ||
resources: | ||
limits: | ||
memory: "100Mi" | ||
requests: | ||
memory: "100Mi" | ||
cpu: "50m" | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
privileged: false | ||
securityContext: | ||
seccompProfile: | ||
type: RuntimeDefault |
18 changes: 18 additions & 0 deletions
18
...ltiple-environments/kluctl-single-service/services/api-golang/manifests/IngressRoute.yaml
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,18 @@ | ||
apiVersion: traefik.containo.us/v1alpha1 | ||
kind: IngressRoute | ||
metadata: | ||
name: api-golang | ||
namespace: demo-app | ||
spec: | ||
entryPoints: | ||
- web | ||
routes: | ||
- kind: Rule | ||
match: Host(`{{ sharedVars.hostName }}`) && PathPrefix(`/api/golang`) | ||
middlewares: | ||
- name: strip-api-prefixes | ||
services: | ||
- kind: Service | ||
name: api-golang | ||
port: 8080 | ||
scheme: http |
22 changes: 22 additions & 0 deletions
22
...ple-environments/kluctl-single-service/services/api-golang/manifests/Job.db-migrator.yaml
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 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: db-migrator | ||
namespace: demo-app | ||
annotations: | ||
kluctl.io/hook: pre-deploy | ||
kluctl.io/hook-weight: 2 | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: migrate | ||
image: sidpalas/devops-directive-kubernetes-course-db-migrator:{{ apiGolang.version }} | ||
args: | ||
- -path=/app/migrations | ||
- -database=$(DATABASE_URL)?sslmode=disable | ||
- up | ||
envFrom: | ||
- secretRef: | ||
name: db-migrator-password | ||
restartPolicy: OnFailure |
10 changes: 10 additions & 0 deletions
10
...multiple-environments/kluctl-single-service/services/api-golang/manifests/Middleware.yaml
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,10 @@ | ||
apiVersion: traefik.containo.us/v1alpha1 | ||
kind: Middleware | ||
metadata: | ||
name: strip-api-prefixes-golang | ||
namespace: demo-app | ||
spec: | ||
stripPrefix: | ||
forceSlash: false | ||
prefixes: | ||
- /api/golang |
14 changes: 14 additions & 0 deletions
14
...ents/kluctl-single-service/services/api-golang/manifests/Secret.db-migrator-password.yaml
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,14 @@ | ||
# ⛔️ DONT PUT SECRET FILES IN VCS | ||
# Creating this secret here is a bit of a hack to ensure it exists before | ||
# the db-migrator job which runs as a pre-deploy hook for api-golang | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: db-migrator-password | ||
namespace: demo-app | ||
annotations: | ||
kluctl.io/hook: pre-deploy | ||
kluctl.io/hook-weight: 1 | ||
type: Opaque | ||
stringData: | ||
DATABASE_URL: postgres://postgres:[email protected]:5432/postgres |
9 changes: 9 additions & 0 deletions
9
...g-to-multiple-environments/kluctl-single-service/services/api-golang/manifests/Secret.yml
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,9 @@ | ||
# ⛔️ DONT PUT SECRET FILES IN VCS | ||
apiVersion: v1 | ||
kind: Secret | ||
type: Opaque | ||
metadata: | ||
name: api-golang-database-url | ||
namespace: demo-app | ||
stringData: | ||
DATABASE_URL: postgres://postgres:[email protected]:5432/postgres |
12 changes: 12 additions & 0 deletions
12
...to-multiple-environments/kluctl-single-service/services/api-golang/manifests/Service.yaml
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,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: api-golang | ||
namespace: demo-app | ||
spec: | ||
selector: | ||
app: api-golang | ||
ports: | ||
- protocol: TCP | ||
port: 8000 | ||
targetPort: 8000 |
2 changes: 2 additions & 0 deletions
2
12-deploying-to-multiple-environments/kluctl-single-service/services/deployment.yaml
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,2 @@ | ||
deployments: | ||
- include: api-golang |
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
1 change: 1 addition & 0 deletions
1
12-deploying-to-multiple-environments/kluctl/services/api-golang/config/production.yaml
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
apiGolang: | ||
version: 0.3.0 # PRODUCTION_IMAGE_TAG | ||
replicas: 2 |
1 change: 1 addition & 0 deletions
1
12-deploying-to-multiple-environments/kluctl/services/api-golang/config/staging.yaml
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
apiGolang: | ||
version: 0.3.0-2-g29b7fb5 # STAGING_IMAGE_TAG | ||
replicas: 1 |
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
1 change: 0 additions & 1 deletion
1
12-deploying-to-multiple-environments/kluctl/third-party/traefik/kustomization.yaml
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
resources: | ||
- Namespace.yaml | ||
- helm-rendered.yaml # generated at deploy time | ||
|
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
2 changes: 1 addition & 1 deletion
2
...ltiple-environments/kustomize/staging/client-react/patches/IngressRoute.replace-host.yaml
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
- op: replace | ||
path: /spec/routes/0/match | ||
value: "Host(`kubernetes-course.devopsdirective.com`)" | ||
value: "Host(`kubernetes-course-staging.devopsdirective.com`)" |