我使用此处的教程在 VirtualBox (centos7) 上安装了 Kubernetes 集群。
这是我的设置:
- kube-master - 10.1.10.152(etcd、kube-apiserver、kube-controller-manager、kube-scheduler)
- kube-minion1 - 10.1.10.153(kube-proxy、kubelet、docker、flanneld)
当我完成设置时,一切看起来都很好:
$ kubectl get nodes
NAME LABELS STATUS
kube-minion1 kubernetes.io/hostname=kube-minion1 Ready
我尝试使用以下配置添加 mysql pod 和服务:
$ cat mysql.yaml
apiVersion: v1
kind: Pod
metadata:
name: mysql
labels:
name: mysql
spec:
containers:
- resources:
limits :
cpu: 1
image: mysql
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: qwe123
ports:
- containerPort: 3306
name: mysql
$ cat mysql-service.yaml
apiVersion: v1
kind: Service
metadata:
labels:
name: mysql
name: mysql
spec:
publicIPs:
- 10.1.10.153
ports:
# the port that this service should serve on
- port: 3306
# label keys and values that must match in order to receive traffic for this service
selector:
name: mysql
请注意,我确实提供了 publicIPs = 10.1.10.153。一旦 mysql.yaml 和 mysql-service.yaml 都被注入,这就是我得到的:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
mysql 1/1 Running 0 31s
$ kubectl get services
NAME LABELS SELECTOR IP(S) PORT(S)
kubernetes component=apiserver,provider=kubernetes <none> 10.254.0.1 443/TCP
mysql name=mysql name=mysql 10.254.215.138 3306/TCP
$ kubectl describe service mysql
Name: mysql
Namespace: default
Labels: name=mysql
Selector: name=mysql
Type: ClusterIP
IP: 10.254.215.138
Port: <unnamed> 3306/TCP
Endpoints: 172.17.17.5:3306
Session Affinity: None
No events.
所以我遇到的问题是无法使用 10.1.10.153 访问 mysql。我能够与mysql通信的唯一方法是使用10.254.215.138从minion主机访问
为什么我无法使用 10.1.10.153 访问它?有没有办法让它工作?
谢谢-D