4 Commits

Author SHA1 Message Date
ducoterra
31aef36ffd Upgrade to nginx ingress
Use new nginx ingress. Don't use .gitlab-ci for now until vault
integration makes sense.
2021-05-20 15:00:17 -04:00
ducoterra
aef6a98f98 upgrade ingress 2020-12-11 17:21:09 -05:00
ducoterra
99e4fa3c79 add table of contents for day 5 2020-12-08 19:50:19 -05:00
ducoterra
f9cc52cc83 finish day 5 2020-12-08 19:43:39 -05:00
7 changed files with 89 additions and 104 deletions

View File

@@ -1,34 +1,34 @@
variables: # variables:
CI_PROJECT_DIR: "." # CI_PROJECT_DIR: "."
CI_REGISTRY_IMAGE: hub.ducoterra.net/ducoterra/python-docs-2020 # CI_REGISTRY_IMAGE: hub.ducoterra.net/ducoterra/python-docs-2020
DEPLOY: pythondocs2020 # DEPLOY: pythondocs2020
stages: # stages:
- build # - build
- deploy # - deploy
build: # build:
only: # only:
variables: # variables:
- $CI_COMMIT_TAG # - $CI_COMMIT_TAG
stage: build # stage: build
image: # image:
name: gcr.io/kaniko-project/executor:debug # name: gcr.io/kaniko-project/executor:debug
entrypoint: [""] # entrypoint: [""]
script: # script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG # - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
deploy: # deploy:
stage: deploy # stage: deploy
only: # only:
variables: # variables:
- $CI_COMMIT_TAG # - $CI_COMMIT_TAG
image: # image:
name: debian:10 # name: debian:10
entrypoint: [""] # entrypoint: [""]
script: # script:
- apt -qq update >> /dev/null && apt -qq install -y curl gettext >> /dev/null # - apt -qq update >> /dev/null && apt -qq install -y curl gettext >> /dev/null
- curl -o /usr/bin/kubectl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl # - curl -o /usr/bin/kubectl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
- chmod +x /usr/bin/kubectl # - chmod +x /usr/bin/kubectl
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash # - curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- helm upgrade --install $DEPLOY ./helm --set image=$CI_REGISTRY_IMAGE --set tag=$CI_COMMIT_TAG # - helm upgrade --install $DEPLOY ./helm --set image=$CI_REGISTRY_IMAGE --set tag=$CI_COMMIT_TAG

View File

@@ -336,3 +336,27 @@ If we want our menu functions to be useful outside our menu app we have some wor
12. Now type `update = menu.update_people()` and press ++enter++. Nothing should print. 12. Now type `update = menu.update_people()` and press ++enter++. Nothing should print.
13. Wait a moment for "successfully updated people." to print to the terminal 13. Wait a moment for "successfully updated people." to print to the terminal
14. Type `people = menu.list_people(update)`. Your people should list! You successfully turned your menu into an importable package! 14. Type `people = menu.list_people(update)`. Your people should list! You successfully turned your menu into an importable package!
15. Type `exit()` to exit.
### Using our imported menu
For our last trick we'll use our menu functions in a new program.
1. Create a new file named "print_people.py"
![print_people](img/day5/print.gif)
2. Add the following:
```python
from menu import update_people, list_people
from concurrent.futures import wait
update = update_people()
wait([update])
list_people(update)
```
3. Type `python print_people.py` and press ++enter++ to run your program. You should see your people print after a while.
Congratulations! You've just imported a program you wrote to communciate with an API and used it to do something automatically.

BIN
docs/img/day5/print.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@@ -38,4 +38,5 @@
### [Day 5](day5.md): import ### [Day 5](day5.md): import
- "import" - "import"
- - Breaking apart our terrible weather app
- Importing our menu

View File

@@ -1,78 +1,36 @@
apiVersion: traefik.containo.us/v1alpha1 apiVersion: networking.k8s.io/v1
kind: IngressRoute kind: Ingress
metadata: metadata:
name: {{ .Release.Name }}-internal-tls
annotations: annotations:
kubernetes.io/ingress.class: traefik-internal cert-manager.io/cluster-issuer: letsencrypt-prod
kubernetes.io/ingress.class: nginx
name: {{ .Release.Name }}
spec: spec:
entryPoints: rules:
- websecure - host: {{ .Release.Name }}.ducoterra.net
http:
paths:
- backend:
service:
name: {{ .Release.Name }}
port:
number: {{ .Values.port }}
path: /
pathType: Prefix
tls: tls:
certResolver: myresolver - hosts:
domains: - {{ .Release.Name }}.ducoterra.net
- main: "*.ducoterra.net" secretName: {{.Release.Name}}-tls-cert
routes:
- match: Host(`{{ .Release.Name }}.ducoterra.net`)
kind: Rule
services:
- name: {{ .Release.Name }}
port: {{ .Values.port }}
--- ---
apiVersion: cert-manager.io/v1
apiVersion: traefik.containo.us/v1alpha1 kind: Certificate
kind: IngressRoute
metadata: metadata:
name: {{ .Release.Name }}-internal-web name: {{.Release.Name}}.ducoterra.net
annotations:
kubernetes.io/ingress.class: traefik-internal
spec: spec:
entryPoints: secretName: {{.Release.Name}}-tls-cert
- web issuerRef:
routes: name: letsencrypt-prod
- match: Host(`{{ .Release.Name }}.ducoterra.net`) kind: ClusterIssuer
kind: Rule commonName: {{.Release.Name}}.ducoterra.net
services: dnsNames:
- name: {{ .Release.Name }} - {{.Release.Name}}.ducoterra.net
port: {{ .Values.port }}
middlewares:
- name: httpsredirect
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ .Release.Name }}-external-tls
annotations:
kubernetes.io/ingress.class: traefik-external
spec:
entryPoints:
- websecure
tls:
certResolver: myresolver
routes:
- match: Host(`{{ .Release.Name }}.ducoterra.net`)
kind: Rule
services:
- name: {{ .Release.Name }}
port: {{ .Values.port }}
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ .Release.Name }}-external-web
annotations:
kubernetes.io/ingress.class: traefik-external
spec:
entryPoints:
- web
routes:
- match: Host(`{{ .Release.Name }}.ducoterra.net`)
kind: Rule
services:
- name: {{ .Release.Name }}
port: {{ .Values.port }}
middlewares:
- name: httpsredirect

View File

@@ -6,6 +6,7 @@ nav:
- Day 2: day2.md - Day 2: day2.md
- Day 3: day3.md - Day 3: day3.md
- Day 4: day4.md - Day 4: day4.md
- Day 5: day5.md
theme: theme:
name: material name: material
markdown_extensions: markdown_extensions:

1
setenv.sh Executable file
View File

@@ -0,0 +1 @@
kubectl config set current-context k3os-alpha.dnet-ducoterra-websites