3 Commits
0.2.1 ... 0.2.4

Author SHA1 Message Date
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
5 changed files with 44 additions and 43 deletions

View File

@@ -335,4 +335,28 @@ If we want our menu functions to be useful outside our menu app we have some wor
11. Type `people = menu.list_people()` and press ++enter++. You should see `None` print. 11. Type `people = menu.list_people()` and press ++enter++. You should see `None` print.
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,31 +1,27 @@
apiVersion: traefik.containo.us/v1alpha1 apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute kind: IngressRoute
metadata: metadata:
name: {{ .Release.Name }}-internal-tls name: {{ .Release.Name }}-tls
annotations: annotations:
kubernetes.io/ingress.class: traefik-internal kubernetes.io/ingress.class: traefik
spec: spec:
entryPoints: entryPoints:
- websecure - websecure
tls: tls:
certResolver: myresolver certResolver: duconet
domains:
- main: "*.ducoterra.net"
routes: routes:
- match: Host(`{{ .Release.Name }}.ducoterra.net`) - match: Host(`{{ .Release.Name }}.ducoterra.net`)
kind: Rule kind: Rule
services: services:
- name: {{ .Release.Name }} - name: {{ .Release.Name }}
port: {{ .Values.port }} port: {{ .Values.port }}
--- ---
apiVersion: traefik.containo.us/v1alpha1 apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute kind: IngressRoute
metadata: metadata:
name: {{ .Release.Name }}-internal-web name: {{ .Release.Name }}
annotations: annotations:
kubernetes.io/ingress.class: traefik-internal kubernetes.io/ingress.class: traefik
spec: spec:
entryPoints: entryPoints:
- web - web
@@ -36,43 +32,22 @@ spec:
- name: {{ .Release.Name }} - name: {{ .Release.Name }}
port: {{ .Values.port }} port: {{ .Values.port }}
middlewares: middlewares:
- name: httpsredirect - name: httpsredirect-{{ .Release.Name }}
--- ---
apiVersion: traefik.containo.us/v1alpha1 apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute kind: Middleware
metadata: metadata:
name: {{ .Release.Name }}-external-tls name: httpsredirect-{{ .Release.Name }}
annotations:
kubernetes.io/ingress.class: traefik-external
spec: spec:
entryPoints: redirectScheme:
- websecure scheme: https
tls: permanent: true
certResolver: myresolver
routes:
- match: Host(`{{ .Release.Name }}.ducoterra.net`)
kind: Rule
services:
- name: {{ .Release.Name }}
port: {{ .Values.port }}
--- ---
apiVersion: traefik.containo.us/v1alpha1 apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute kind: Middleware
metadata: metadata:
name: {{ .Release.Name }}-external-web name: basic-auth-{{ .Release.Name }}
annotations:
kubernetes.io/ingress.class: traefik-external
spec: spec:
entryPoints: basicAuth:
- web secret: authsecret
routes: removeHeader: true
- 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: