1. 程式人生 > >k8s遇坑:The connection to the server k8s-api.virtual.local:6443 was refused - did you specify the right host or port?

k8s遇坑:The connection to the server k8s-api.virtual.local:6443 was refused - did you specify the right host or port?

sys doc 讀數 true yaml pass manager meta etcd

k8s坑The connection to the server localhost:8080 was refused - did you specify the right host or port
2019年01月08日 17:21:06 金柱 閱讀數:47

定義一個mysql的RC文件:mysql-rc.yaml

apiVersion: v1
kind: ReplicationController
metadata:
  name: mysql
spec:
  replicas: 1
  selector:
    app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - name: mysql
        image: mysql
        ports:
        - containerPort: 3306
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: "123456"



發布到k8s集群中

# kubectl create -f mysql-rc.yaml

    1
    2

報錯:

The connection to the server localhost:8080 was refused - did you specify the right host or port?

    1
    2

沒有啟動k8s集群或啟動順序不對,重新按一下順序啟動所有服務:

# systemctl start etcd
# systemctl start docker
# systemctl start kube-apiserver
# systemctl start kube-controller-manager
# systemctl start kube-scheduler
# systemctl start kubelet
# systemctl start kube-proxy



然後再發布mysql-rc.yaml就不報錯了

k8s遇坑:The connection to the server k8s-api.virtual.local:6443 was refused - did you specify the right host or port?