added Don früh
This commit is contained in:
21
k8s/deployment
Normal file
21
k8s/deployment
Normal file
@@ -0,0 +1,21 @@
|
||||
mkdir -p ~/web && cd web
|
||||
kubectl config set-context --current --namespace web
|
||||
# Starten Sie eine einzelne Instanz von Nginx
|
||||
kubectl create deployment nginx --image=nginx
|
||||
# Zeigen Sie die Dokumentation für Pod und SVC Manifeste an
|
||||
kubectl explain pods.spec
|
||||
kubectl explain svc.spec
|
||||
kubectl explain deployment.spec
|
||||
kubectl create deployment web \
|
||||
--image=bee42/whoami:2.2.0 \
|
||||
--dry-run=client \
|
||||
--output=yaml >deployment.yaml
|
||||
cat deployment.yaml
|
||||
kubectl apply -f deployment.yaml
|
||||
kubectl get deploy
|
||||
kubectl get pods
|
||||
kubectl get rs
|
||||
kubectl delete deploy web
|
||||
cat deployment.yaml | kubectl apply -f -
|
||||
|
||||
kubectl scale deployment nginx --replicas 1
|
||||
44
k8s/install_nginx
Normal file
44
k8s/install_nginx
Normal file
@@ -0,0 +1,44 @@
|
||||
cd ~
|
||||
mkdir nginx && cd nginx
|
||||
|
||||
# namespace
|
||||
kubectl create namespace nginx
|
||||
kubectl config set-context --current --namespace nginx
|
||||
|
||||
# create pod and service nginx
|
||||
kubectl run nginx --image nginx --labels run=nginx --dry-run=client -o yaml >nginx.yaml
|
||||
kubectl apply -f nginx.yaml
|
||||
|
||||
kubectl expose pod nginx -o yaml --port 80 --target-port 80 --dry-run=client >nginx-svc.yaml
|
||||
kubectl apply -f nginx-svc.yaml
|
||||
|
||||
# access service
|
||||
kubectl run curl --tty -i --image curlimages/curl -- /bin/sh
|
||||
curl -i http://nginx
|
||||
exit
|
||||
|
||||
# start new pod for nginx service ... same labels
|
||||
kubectl run nginx1 --image nginx --labels run=nginx --dry-run=client -o yaml >nginx1.yaml
|
||||
kubectl apply -f nginx1.yaml
|
||||
|
||||
# describe manifest
|
||||
kubectl describe pods nginx
|
||||
kubectl describe svc nginx
|
||||
|
||||
# deploy pod with nginx 1.19.7
|
||||
kubectl set image po nginx nginx=nginx:1.19.7
|
||||
kubectl set image po nginx1 nginx1=nginx:1.19.7
|
||||
|
||||
#or
|
||||
kubectl set image po *=nginx:1.19.8 -l run=nginx
|
||||
|
||||
kubectl describe pods nginx
|
||||
kubectl describe pods nginx1
|
||||
kubectl describe svc nginx
|
||||
kubectl get pods
|
||||
kubectl get ep
|
||||
kubectl get svc
|
||||
kubectl attach curl --tty -i
|
||||
curl http://nginx
|
||||
exit
|
||||
kubectl attach -ti curl
|
||||
17
k8s/nginx/nginx-svc.yaml
Normal file
17
k8s/nginx/nginx-svc.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
namespace: nginx
|
||||
labels:
|
||||
name: nginx
|
||||
name: nginx
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
protocol: TCP
|
||||
targetPort: 80
|
||||
selector:
|
||||
run: nginx
|
||||
status:
|
||||
loadBalancer: {}
|
||||
15
k8s/nginx/nginx1.yaml
Normal file
15
k8s/nginx/nginx1.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
name: nginx
|
||||
name: nginx1
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
name: nginx1
|
||||
resources: {}
|
||||
dnsPolicy: ClusterFirst
|
||||
restartPolicy: Always
|
||||
status: {}
|
||||
4
k8s/nginx/nginx_namespace.yaml
Normal file
4
k8s/nginx/nginx_namespace.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: nginx
|
||||
17
k8s/nginx/nginx_pod.yaml
Normal file
17
k8s/nginx/nginx_pod.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: nginx
|
||||
namespace: nginx
|
||||
labels:
|
||||
name: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx:1.19.3
|
||||
resources:
|
||||
limits:
|
||||
memory: "128Mi"
|
||||
cpu: "500m"
|
||||
ports:
|
||||
- containerPort: 80
|
||||
13
k8s/nginx/nginx_service.yaml
Normal file
13
k8s/nginx/nginx_service.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nginx
|
||||
namespace: nginx
|
||||
labels:
|
||||
name: nginx
|
||||
spec:
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 80
|
||||
56
k8s/pods
56
k8s/pods
@@ -13,4 +13,58 @@ kubectl run whoami --image bee42/whoami:2.2.0 --expose --port 80
|
||||
kubectl get pod whoami -o yaml
|
||||
|
||||
# kann zur erstellung der YAML genutzt werden.
|
||||
kubectl run whoami2 --image bee42/whoami:2.2.0 --labels=run=whoami --dry-run=client -o yaml >whoami-pod.yaml
|
||||
kubectl run whoami2 --image bee42/whoami:2.2.0 --labels=run=whoami --dry-run=client -o yaml >whoami-pod.yaml
|
||||
|
||||
# Show Labels
|
||||
kubectl get pods --show-labels
|
||||
|
||||
# Test iin Pod
|
||||
kubectl run curl --tty -i --image curlimages/curl -- /bin/sh
|
||||
curl -i http://nginx
|
||||
|
||||
# port weiterleiten
|
||||
kubectl port-forward services/nginx 8091:80 &
|
||||
|
||||
# scale Pods
|
||||
|
||||
kubectl scale deployments/web --replicas=3
|
||||
|
||||
kubectl set image deployment/web nginx=nginx:1.19.4
|
||||
kubectl rollout status -w deployment/web
|
||||
kubectl rollout undo deployment/web
|
||||
kubectl rollout status -w deployment/web
|
||||
kubectl rollout history deployment/web
|
||||
kubectl rollout undo deployment/web --to-revision=1
|
||||
|
||||
# Better annotate replicaset !!
|
||||
kubectl annotate deployment web kubernetes.io/change-cause="Release 1.19.3" --overwrite=true
|
||||
|
||||
#or
|
||||
|
||||
kubectl get rs
|
||||
NAME DESIRED CURRENT READY AGE
|
||||
web-85dfdff5d 0 0 0 28m
|
||||
web-548df7676c 0 0 0 46m
|
||||
web-6f4f87dd45 3 3 3 26m
|
||||
kubectl annotate rs web-6f4f87dd45 kubernetes.io/change-cause="Release 1.19.5" --overwrite=true
|
||||
kubectl rollout history deploy web
|
||||
deployment.apps/web
|
||||
REVISION CHANGE-CAUSE
|
||||
4 <none>
|
||||
5 <none>
|
||||
6 Release 1.19.5
|
||||
# new deployment
|
||||
|
||||
kubectl get rs -o json |jq -r .items[].metadata.annotations.\"deployment.kubernetes.io/revision\"
|
||||
3
|
||||
6
|
||||
5
|
||||
|
||||
|
||||
|
||||
#cat pod.json | kubectl replace -f -
|
||||
#kubectl replace --force -f ./pod.json
|
||||
kubectl get pods
|
||||
kubectl get pod <web pod> -o yaml | sed 's/\(image: nginx\):.*$/\1:1.19.3/' | kubectl replace -f -
|
||||
|
||||
#kubectl get pod web-548df7676c-v48kv -o yaml | sed 's/\(image: nginx\):.*$/\1:1.19.4/' | kubectl replace -f - web-548df7676c-rzp7v
|
||||
Reference in New Issue
Block a user