Kubernetes

每天5分钟玩转容器技术

Docker

K8s

kubeadm token list

# get --discovery-token-ca-cert-hash
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'

搭建



测试

#################
# busybox.yaml
#################
apiVersion: v1
kind: Pod
metadata:
  name: busybox
  namespace: default
spec:
  containers:
  - image: busybox
    command:
      - sleep
      - "3600"
    imagePullPolicy: IfNotPresent
    name: busybox
  restartPolicy: Always
sudo kubectl create -f ./busybox.yaml
sudo kubectl get rc
sudo kubectl get pods
sudo kubectl describe pod mysql

FAQ

问题:

########################3
# Centos7
########################3

#sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml
$ sudo kubectl apply -f ./kube-flannel.yml
unable to recognize "./kube-flannel.yml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./kube-flannel.yml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./kube-flannel.yml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./kube-flannel.yml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
unable to recognize "./kube-flannel.yml": Get http://localhost:8080/api?timeout=32s: dial tcp [::1]:8080: connect: connection refused
The connection to the server localhost:8080 was refused - did you specify the right host or port

解决: 需要开启 api server 代理端口:

# 查看端口是否代理:
$ curl localhost:8080/api

# 开启端口代理:
$ kubectl proxy --port=8080 &