新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件
This commit is contained in:
39
learn/learn-kubernetes-master/kiamol/ch06/lab/README.md
Normal file
39
learn/learn-kubernetes-master/kiamol/ch06/lab/README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Ch06 lab
|
||||
|
||||
Run the app:
|
||||
|
||||
```
|
||||
kubectl apply -f lab/numbers/
|
||||
```
|
||||
|
||||
Get the URL to browse to:
|
||||
|
||||
```
|
||||
kubectl get svc numbers-web -o jsonpath='http://{.status.loadBalancer.ingress[0].*}:8086'
|
||||
```
|
||||
|
||||
> Browse and try to get a random number, the app fails.
|
||||
|
||||
## Sample Solution
|
||||
|
||||
Add the RNG label to a node:
|
||||
|
||||
```
|
||||
kubectl label node $(kubectl get nodes -o jsonpath='{.items[0].metadata.name}') rng=hw
|
||||
```
|
||||
|
||||
Deploy the new resources - a [Deployment](solution/web-deployment.yaml) for the web app and a [DaemonSet](solution/api-daemonset.yaml) for the API:
|
||||
|
||||
```
|
||||
kubectl apply -f lab/solution/
|
||||
```
|
||||
|
||||
> Refresh the browser and confirm you can get a random number.
|
||||
|
||||
Delete the old resources by their labels:
|
||||
|
||||
```
|
||||
kubectl get all -l kiamol=ch06-lab
|
||||
|
||||
kubectl delete all -l kiamol=ch06-lab
|
||||
```
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: numbers-api
|
||||
labels:
|
||||
kiamol: ch06-lab
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
app: numbers-api
|
||||
type: ClusterIP
|
||||
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: numbers-api
|
||||
labels:
|
||||
kiamol: ch06-lab
|
||||
spec:
|
||||
containers:
|
||||
- name: api
|
||||
image: kiamol/ch03-numbers-api
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: numbers-web
|
||||
labels:
|
||||
kiamol: ch06-lab
|
||||
spec:
|
||||
ports:
|
||||
- port: 8086
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: numbers-web
|
||||
type: LoadBalancer
|
||||
@@ -0,0 +1,18 @@
|
||||
apiVersion: v1
|
||||
kind: ReplicationController
|
||||
metadata:
|
||||
name: numbers-web
|
||||
labels:
|
||||
kiamol: ch06-lab
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
app: numbers-web
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: numbers-web
|
||||
spec:
|
||||
containers:
|
||||
- name: web
|
||||
image: kiamol/ch03-numbers-web
|
||||
@@ -0,0 +1,20 @@
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: numbers-api
|
||||
labels:
|
||||
kiamol: ch06-lab
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: numbers-api
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: numbers-api
|
||||
spec:
|
||||
containers:
|
||||
- name: api
|
||||
image: kiamol/ch03-numbers-api
|
||||
nodeSelector:
|
||||
rng: hw
|
||||
@@ -0,0 +1,19 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: numbers-web
|
||||
labels:
|
||||
kiamol: ch06-lab
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: numbers-web
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: numbers-web
|
||||
spec:
|
||||
containers:
|
||||
- name: web
|
||||
image: kiamol/ch03-numbers-web
|
||||
Reference in New Issue
Block a user