show
source <(kubectl completion bash)
echo "source <(kubectl completion bash)" >> ~/.bashrc
show
KUBECONFIG=~/.kube/config:~/.kube/kubconfig2
show
# create a file named role.yml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: pod-reader
rules:
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "watch", "list"]
# create the role
kubectl apply -f role.yml
show
# create a file named role-binding.yml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: pod-reader
namespace: default
subjects:
- kind: User
name: dev
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: Role
name: pod-reader
apiGroup: rbac.authorization.k8s.io
show
kubectl config set-context --current --namespace=ggckad-s2
show
kubectl config set-context gce --user=cluster-admin --namespace=foo \
&& kubectl config use-context gce
show
kubectl get services --sort.by=.metadata.name
show
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="ExternalIP")].address}'
show
# check the livez endpoint
curl -k https://localhost:6443/livez?verbose
# or
kubectl get --raw='/livez?verbose'
# check the readyz endpoint
curl -k https://localhost:6443/readyz?verbose
# or
kubectl get --raw='/readyz?verbose'
# check the healthz endpoint
curl -k https://localhost:6443/healthz?verbose
# or
kubectl get --raw='/healthz?verbose'
show
kubectl get po --field-selector status.phase=Running
show
kubectl get svc --field-selector metadata.namespace=default
show
kubectl api-resources
show
systemctl list-unit-files --type service --all | grep kube
show
systemctl status kubelet