Kubernetes Crash Course Blog Post(KR) - no link yet
Requirement: Mac model 2010+, OS 10.12+
Install docker for mac.
Follow docker guide to increase resource limit(need to set memory to 8GB+).
Install Go download from golang.org
You can manage Go verions with gvm
### download kubectl 1.16.0
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/darwin/amd64/kubectl
chmod -x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
### if kubectl isn't executable
chmod 755 /usr/local/bin/kubectl
Refer to KIND for more details
GO111MODULE="on" go get sigs.k8s.io/[email protected]
export PATH="$PATH:$(go env GOPATH)/bin"
alias k='kubectl'
alias chrome="/Applications/Google\\ \\Chrome.app/Contents/MacOS/Google\\ \\Chrome"
kubectl command shell auto-completion
### for oh-my-zsh
plugins=(... kubectl)
- k8s context/namespace changer kubectx/kubens
- Awesome k8s shell prompt kube ps1
- Very cool k8s CLI manage tool k9s
- Multiple pods log tool for k8s stern
Will create 1 master and 2 worker nodes.
kind create cluster --name kind-m --config kind-test-config.yaml
Add configs from '.kube/kind-config-kind-m' to '.kube/config' file or:
export KUBECONFIG="$(kind get kubeconfig-path --name="kind-m")"
Note: k8s config file may contain multiple configs.
kubectl cluster-info
kubectl get nodes
kubectl get pods --all-namespaces
Refer to metrics-server for more information
kubectl apply -f ./metrics-server
Installation Guide
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
### create service with nodeport 32080, 32433
kubectl apply -f ./ingress-nginx/
Deploy MariaDB:
kubectl create namespace wordpress
kubectl apply -f ./mysql
### Check Stateful Sets
kubectl get sts -n wordpress
kubectl describe sts mysql -n wordpress
Deploy Wordpress:
### get you local ip
IP=$(ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}')
### replace ingress host with your IP
sed -i.bak "s/host.*/host: blog."$IP".nip.io/g" ./wordpress/ingress.yaml
kubectl apply -f ./wordpress
### edit deployment
kubectl edit deploy wordpress
### port forward to check if wordpress is running correctly
WPOD=$(kubectl get -n wordpress pod -l app=wordpress -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward pod/$WPOD 8090:80 -n wordpress
Scale in/out Deployments:
kubectl scale deploy wordpress --replicas=3 -n wordpress
kubectl scale deploy wordpress --replicas=1 -n wordpress
### check services for wordpress
kubectl get svc -n wordpress
### check ingress
kubectl get ingress -n wordpress
### other commands
k explain deployment --recursive
k explain svc --recursive
k get pods -o wide --sort-by="{.spec.nodeName}"
Intall socat to expose nodeport on local 80 port:
docker run -d --name kind-proxy-80 \
--publish 80:80 \
--link kind-m-control-plane:target \
alpine/socat \
tcp-listen:80,fork,reuseaddr tcp-connect:target:32080
Test with your own DNS:
chrome http://blog.$IP.nip.io
kubectl --namespace=wordpress delete --all
kubectl delete --namespace wordpress
kind delete cluster --name kind-m
### remove socat
docker rm -f kind-proxy-80
Install dashboard:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta4/aio/deploy/recommended.yaml
### Run below to fix auth
k apply -f ./dashboard
### Run below and copy hash code from token:
./dashboard/getsecret.sh
### Run below from another terminal:
k proxy
Click this link to open dashboard in your web browser.
To disable session time-out:
kubectl edit deployment kubernetes-dashboard -n kube-system
### add following after arg:
- args:
- --token-ttl=0
### metrics-server must be running
kubectl apply -f ./extra
Refer to K8S Debug Services for details
# Run alpine image to troubleshoot
kubectl run -it --rm --restart=Never alpine --image=alpine sh
# lookup service
nslookup wordpress
# check svc name/IP
wget -SO- wordpress:8081
wget -SO- <SVC_IP>:8081
# check pod endpoint
wget -SO- <POD ID:80>
subicura님의 쿠버네티스 시작하기 블로그
K8S Deep Dive: API Server Part1, Part2, Part3
이어형님 딥다이브
Dockerfile Best Practices