新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件
This commit is contained in:
60
learn/learn-kubernetes-master/kiamol/ch10/lab/README.md
Normal file
60
learn/learn-kubernetes-master/kiamol/ch10/lab/README.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Ch10 lab
|
||||
|
||||
Run the app using plain manifests (from this `lab` folder):
|
||||
|
||||
```
|
||||
kubectl apply -f ./todo-list/
|
||||
```
|
||||
|
||||
Get the URL and browse:
|
||||
|
||||
```
|
||||
kubectl get svc todo-web -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:8080'
|
||||
```
|
||||
|
||||
|
||||
## Sample Solution
|
||||
|
||||
My Helm chart templates the Kubernetes manifests for all the resources:
|
||||
|
||||
- [templates/todo-web-configMap.yaml](./ch10-lab-solution/templates/todo-web-configMap.yaml)
|
||||
- [templates/todo-web-deployment.yaml](./ch10-lab-solution/templates/todo-web-deployment.yaml)
|
||||
- [templates/todo-web-service.yaml](./ch10-lab-solution/templates/todo-web-service.yaml)
|
||||
|
||||
The [default values](./ch10-lab-solution/values.yaml) specify the Test environment and a Service port of 8080.
|
||||
|
||||
Validate the chart:
|
||||
|
||||
```
|
||||
helm lint ./ch10-lab-solution
|
||||
```
|
||||
|
||||
Install the test setup:
|
||||
|
||||
```
|
||||
helm install lab-test ./ch10-lab-solution
|
||||
```
|
||||
|
||||
> You can browse on port 8080, and the /config path returns a 404
|
||||
|
||||
Install the dev setup:
|
||||
|
||||
```
|
||||
helm install -f dev-values.yaml lab-dev ./ch10-lab-solution
|
||||
```
|
||||
|
||||
> You can browse on port 8088, and the /config path is working
|
||||
|
||||
## Teardown
|
||||
|
||||
Uninstall the Helm releases:
|
||||
|
||||
```
|
||||
helm uninstall lab-test lab-dev
|
||||
```
|
||||
|
||||
Delete other lab resources by their labels:
|
||||
|
||||
```
|
||||
kubectl delete all -l kiamol=ch10-lab
|
||||
```
|
||||
@@ -0,0 +1,23 @@
|
||||
# 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
|
||||
*.orig
|
||||
*~
|
||||
# Various IDEs
|
||||
.project
|
||||
.idea/
|
||||
*.tmproj
|
||||
.vscode/
|
||||
@@ -0,0 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: ch10-lab-solution
|
||||
description: Solution to Kiamol ch10 lab
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: 1.0.0
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-config
|
||||
labels:
|
||||
kiamol: ch10-lab
|
||||
data:
|
||||
config.json: |-
|
||||
{
|
||||
"ConfigController": {
|
||||
"Enabled" : {{ .Values.configControllerEnabled }}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
labels:
|
||||
kiamol: ch10-lab
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ .Release.Name }}
|
||||
environment: {{ .Values.environment | lower }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ .Release.Name }}
|
||||
environment: {{ .Values.environment | lower }}
|
||||
spec:
|
||||
containers:
|
||||
- name: web
|
||||
image: kiamol/ch04-todo-list
|
||||
env:
|
||||
- name: ASPNETCORE_ENVIRONMENT
|
||||
value: {{ .Values.environment | title }}
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: "/app/config"
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: {{ .Release.Name }}-config
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
labels:
|
||||
kiamol: ch10-lab
|
||||
spec:
|
||||
ports:
|
||||
- port: {{ .Values.servicePort }}
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: {{ .Release.Name }}
|
||||
environment: {{ .Values.environment | lower }}
|
||||
type: {{ .Values.serviceType }}
|
||||
@@ -0,0 +1,8 @@
|
||||
# environment - Dev, Test or Prod
|
||||
environment: Test
|
||||
# whether the config UI is enabled
|
||||
configControllerEnabled: false
|
||||
# port for the Service:
|
||||
servicePort: 8080
|
||||
# type of the Service:
|
||||
serviceType: LoadBalancer
|
||||
@@ -0,0 +1,3 @@
|
||||
environment: Dev
|
||||
configControllerEnabled: true
|
||||
servicePort: 8088
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: todo-web-config
|
||||
labels:
|
||||
kiamol: ch10-lab
|
||||
# ConfigController.Enabled should be parameterized
|
||||
data:
|
||||
config.json: |-
|
||||
{
|
||||
"ConfigController": {
|
||||
"Enabled" : false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: todo-web # this needs to be templated
|
||||
labels:
|
||||
kiamol: ch10-lab
|
||||
spec:
|
||||
selector:
|
||||
matchLabels: # this needs to be templated
|
||||
app: todo-web
|
||||
environment: test
|
||||
template:
|
||||
metadata:
|
||||
labels: # this needs to be templated
|
||||
app: todo-web
|
||||
environment: test
|
||||
spec:
|
||||
containers:
|
||||
- name: web
|
||||
image: kiamol/ch04-todo-list
|
||||
env:
|
||||
- name: ASPNETCORE_ENVIRONMENT
|
||||
value: Test # this should be parameterized
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: "/app/config"
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: todo-web-config # this needs to be templated
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: todo-web # this needs to be templated
|
||||
labels:
|
||||
kiamol: ch10-lab
|
||||
spec:
|
||||
ports:
|
||||
- port: 8081 # this should be parameterized
|
||||
targetPort: 80
|
||||
selector: # this needs to be templated
|
||||
app: todo-web
|
||||
environment: test
|
||||
type: LoadBalancer # this should be parameterized
|
||||
Reference in New Issue
Block a user