kubectl create namespace whoami
kubectl config view
kubectl config set-context --current --namespace whoami
# create pod and service
kubectl run whoami --image bee42/whoami:2.2.0 --expose --port 80
kubectl get pods
kubectl get pods -o yaml
# see we created also a service!
kubectl get svc


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

# 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

curl -i -X POST http://carpool:5000/car \
  -H "Content-Type: application/json" \
  --data-binary "@car_2.json"