- Download k8s cluster manager e.g. Docker
- Docker on a laptop is best to start with to get you commands to create images and manage them
- Download kubectl, kops, kubeadm to manage k8s cluster and apps (kops - if youre using AWS, GCE or external cloud infra, else kubectl will do)
- Some of the commands are built for zsh (but w/ a few tweaks can work w/ bash also)
- Download golang
#####################################################################################################
make clean make bin/main-go
curl http://localhost:8001 ({/counter} {/counter/get})
docker build --rm -f docker/Main_Dockerfile -t main-go:latest .
docker image prune
docker system prune
docker image ls
docker run -it main-go /bin/sh
docker run -p 8000:8001 main-go
docker image rm -f main-go
#####################################################################################################
kubectl apply -f k8s/pv-vol.yaml
kubectl apply -f k8s/pv-claim.yaml
kubectl apply -f k8s/main-go.yaml
kubectl apply -f k8s/pv-test.yaml
kubectl apply -f k8s/get-py.yaml
kubectl apply -f k8s/roll-py.yaml
kubectl apply -f k8s/reset-py.yaml
kubectl apply -f k8s/service.yaml
kubectl apply -f k8s/get-service.yaml
kubectl apply -f k8s/roll-service.yaml
kubectl apply -f k8s/reset-service.yaml
kubectl exec -it /bin/sh #####################################################################################################
curl http://localhost:6000/counter/get/get -> Internal microservice curl http://localhost:5000 curl http://localhost:5000/counter/main curl http://localhost:5000/counter/get
curl -X PUT http://localhost:8000/counter/roll/roll -> Internal microservice curl -X PUT http://localhost:5000/counter/roll
curl -X PUT http://localhost:7000/counter/reset/reset -> Internal microservice curl -X PUT http://localhost:5000/counter/reset
kubectl exec -it nfs-dataaccess /bin/sh
kubectl delete pod -l app=main-python kubectl delete pod -l app=get-python kubectl delete pod-l app=roll-python kubectl delete pod -l app=reset-python
kubectl logs -f -n default -l app=main-python kubectl logs -f -n default -l app=get-python kubectl logs -f -n default -l app=roll-python kubectl logs -f -n default -l app=reset-python
#####################################################################################################
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.4.0/aio/deploy/recommended.yaml
kubectl create clusterrolebinding serviceaccounts-cluster-admin --clusterrole=cluster-admin --group=system:serviceaccounts
kubectl proxy
APISERVER=$(kubectl config view --minify | grep server | cut -f 2- -d ":" | tr -d " ") SECRET_NAME=$(kubectl get secrets | grep ^default | cut -f1 -d ' ') TOKEN=$(kubectl describe secret $SECRET_NAME | grep -E '^token' | cut -f2 -d':' | tr -d " ") echo $TOKEN
#####################################################################################################
#####################################################################################################
ssh testuser@10.0.0.228/testuser (this has sudo) /etc/exports
/srv/data *(rw,fsid=0,async,no_subtree_check,no_auth_nlm,insecure,no_root_squash) exportfs -ra
ssh pi@10.0.0.52/ (this has sudo) /etc/exports
/srv/data *(rw,fsid=0,async,no_subtree_check,no_auth_nlm,insecure,no_root_squash) exportfs -ra
/etc/apt/sources.list deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi deb http://archive.raspberrypi.org/debian/ buster main
apt update apt full-upgrade apt-get install nfs-kernel-server systemctl start nfs-kernel-server.service
mount -t nfs -o resvport,nfsvers=4 10.0.0.228:/srv/data mnt/data
kubectl apply -f k8s/nfs-pv-vol.yaml kubectl apply -f k8s/nfs-pv-claim.yaml kubectl apply -f k8s/nfs-pv-test.yaml
kubectl exec -it nfs-dataaccess /bin/sh
curl http://localhost:5000 cat /mnt/data/counter.txt
#####################################################################################################
#####################################################################################################
kubectl apply -f sample/addons (this will install all)
kubectl label namespace default istio-injection=enabled
export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}') export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].port}') export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
curl localhost/counter/get curl -X PUT localhost/counter/roll curl localhost/counter/get
istioctl dashboard kiali kubectl -n istio-system port-forward service/kiali 20001:20001
istioctl dashboard grafana kubectl -n istio-system port-forward service/grafana 3000:3000
istioctl dashboard prometheus kubectl -n istio-system port-forward service/prometheus 9090:9090
for i in $(seq 1 100); do curl -s -X PUT "http://localhost/counter/roll"; echo "\n"; done kubectl logs -f -n default -l app=roll-python
for i in $(seq 1 100); do curl -s "http://localhost/counter/get"; echo "\n"; done kubectl logs -f -n default -l app=main-python
kubectl apply -f k8s/main-gw.yaml
kubectl apply -f k8s/canary-routing.yaml
for i in $(seq 1 100); do curl -s "http://localhost/counter/get"; echo "\n" ; done
seq 1 100 | xargs -n1 -P10 curl -s "http://localhost/counter/get"; echo "\n"; done
kubectl apply -f k8s/header-routing.yaml
curl -H x1-version:v1 localhost/counter/get
curl -H x1-version:v2 localhost/counter/get
Three versions - API based routing - get in one version (v1), roll in another (v2) and reset in yet another (v3).
for i in $(seq 1 100); do curl -s -H x1-version:v2 -X PUT "http://localhost/counter/roll"; curl -s "http://localhost/counter/get"; curl -s -X PUT "http://localhost/counter/reset"; echo "\n" ; done