镜像:https://hub.daocloud.io/#!/repos/f8919a2c-2540-424e-8758-d23cc76b6d80
启动Kubernetes集群
配置Kubernetes网络,在master和nodes上都需要安装flannel
vi /etc/sysconfig/flanneld # Flanneld configuration options # etcd url location. Point this to the server where etcd runs FLANNEL_ETCD_ENDPOINTS="http://192.168.132.148:2379" # etcd config key. This is the configuration key that flannel queries # For address range assignment FLANNEL_ETCD_PREFIX="/atomic.io/network" # Any additional options that you want to pass #FLANNEL_OPTIONS=""
配置etcd中flannel的key,需要在etcd中进行配置(如果做了集群可忽略此步骤)
在master节点上启动
systemctl enable flanneld.service systemctl start flanneld.service service docker restart systemctl restart kube-apiserver.service systemctl restart kube-controller-manager.service systemctl restart kube-scheduler.service
在各个Nodes上启动
systemctl enable flanneld.service
systemctl start flanneld.service
service docker restart
systemctl restart kubelet.service
systemctl restart kube-proxy.service
测试集群
配置dashboard并启动
编辑一个kubernetes-dashboard.yaml文件
ui.yaml
apiVersion: extensions/v1beta1 kind: Deployment metadata: # Keep the name in sync with image version and # gce/coreos/kube-manifests/addons/dashboard counterparts name: kubernetes-dashboard-latest namespace: kube-system spec: replicas: 1 template: metadata: labels: k8s-app: kubernetes-dashboard version: latest kubernetes.io/cluster-service: "true" spec: containers: - name: kubernetes-dashboard image: daocloud.io/daocloud/google_containers_kubernetes-dashboard-amd64:v1.6.1 resources: # keep request = limit to keep this container in guaranteed class limits: cpu: 100m memory: 50Mi requests: cpu: 100m memory: 50Mi ports: - containerPort: 9090 args: - --apiserver-host=http://192.168.132.148:8080 livenessProbe: httpGet: path: / port: 9090 initialDelaySeconds: 30 timeoutSeconds: 30 --- kind: Service metadata: name: kubernetes-dashboard namespace: kube-system labels: k8s-app: kubernetes-dashboard kubernetes.io/cluster-service: "true" spec: selector: k8s-app: kubernetes-dashboard ports: - port: 80 targetPort: 9090
注释:
image 此处要写镜像地址,由于大多数dashboard的镜像国内无法访问,所以找到一个国内可用的
--apiserver-host=http://192.168.132.148:8080 这里为apiserver的地址(node下配置)
创建dashboard
[[email protected]_master ~]# kubectl create -f ui.yaml deployment "kubernetes-dashboard-latest" created service "kubernetes-dashboard" created
查看创建deployment
[[email protected]_master ~]# kubectl get -f ui.yaml NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE deploy/kubernetes-dashboard-latest 1 1 1 1 47m NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE svc/kubernetes-dashboard 10.254.159.141 <none> 80/TCP 47m
[[email protected]_master ~]# kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE kube-system kubernetes-dashboard-latest-1381663337-0wwml 1/1 Running 0 48m
如果status处异常可查看日志
[[email protected]_master ~]# kubectl logs -f kubernetes-dashboard-latest-1381663337-0wwml -n kube-system
[[email protected]_master ~]# kubectl describe po kubernetes-dashboard --namespace=kube-system
正常为
错误(提示无法拉取镜像):
访问web (http://192.168.132.148:8080/ui)
Error: ‘dial tcp 10.1.23.2:9090: getsockopt: connection refused‘
需要检查apiserver的地址设置的是否正确(重启apiserver和kubenets)
http://192.168.132.148:8080/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard/#!/cluster?namespace=kube-system