1.KIND官方文档:https://kind.sigs.k8s.io/docs/user/quick-start/
(1)安装go:https://golang.org/dl/
(2)安装kind
(3)安装docker:https://docs.docker.com/engine/install/ubuntu/
(4) 在主机上作为工具去操作kind中的kubectl, 需要安装kubuctl,教程: https://www.kubernetes.org.cn/installkubectl
2.用kind创建K8S集群:
(1)编写好 yaml文件:如:kind-example-config.yaml
(2)kind create cluster --config kind-example-config.yaml --name kind1 创建集群
3.安装dashboard:
(1)参考安装教程:https://github.com/kubernetes/dashboard:
1。。下载文件:wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.4/aio/deploy/recommended.yaml
2.。。修改文件,映射端口:
3.。。部署文件:
kubectl apply -f recommended.yaml
(2)通过之间创建kind集群的时候映射的端口如3004--》30004,我们就可以通过http://主机IP:3004访问dashboard了
登录需要token,生成方法是:https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md
3.部署mysql+adminer到集群
(1)编写好yml文件:如mysqladminer.yml
apiVersion: v1 kind: ReplicationController metadata: name: mysql-rc labels: name: mysql-rc spec: replicas: 1 selector: name: mysql-pod template: metadata: labels: name: mysql-pod spec: containers: - name: mysql image: mysql args: - "--default-authentication-plugin=mysql_native_password" imagePullPolicy: IfNotPresent ports: - containerPort: 3306 env: - name: MYSQL_ROOT_PASSWORD value: "example" - name: adminer image: adminer imagePullPolicy: IfNotPresent ports: - containerPort: 8080
(2)kubectl apply -f mysqladminer.yml
(3)编写svc yml:如svc_mysqladminer.yml. 也可以与上面的文件写在一起一起部署
apiVersion: v1 kind: Service metadata: name: mysql-svc labels: name: mysql-svc spec: type: NodePort ports: - port: 3306 protocol: TCP targetPort: 3306 name: mysql nodePort: 30001 - port: 8080 protocol: TCP targetPort: 8080 name: adminer nodePort: 30002 selector: name: mysql-pod
(4)部署svc :kubectl apply -f svc_mysqladminer.yml
(5) 访问adminer 主机IP:映射端口30002 (kind 容器暴露到主机的端口)