本帖最后由 梁强 于 2020-3-26 16:00 编辑
环境准备安装systemctl disable firewalld
systemctl stop firewalldyum install -y etcd kubernetessystemctl 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至此,一个单机版的Kubernetes集群环境就安装启动成功了 启动MySQL服务apiVersion: v1
kind: ReplicationController # 副本控制器RC
metadata:
name: mysql # RC 的名称,全局唯一
spec:
replicas: 1 # Pod副本期待数量
selector:
app: mysql # 符合目标的pod拥有此标签
template: # 根据此模板创建Pod的副本(实例)
metadata:
labels:
app: mysql # Pod副本拥有的标签,对应RC的selector
spec:
containers: # pod内容器的定义部分
- name: mysql # 容器的名称
image: mysql # 容器对应的Docker Image
ports:
- containerPort: 3306 # 容器应用监听的端口号
env: # 注入容器内的环境变量
- name: MYSQL_ROOT_PASSWORD
value: "123456"kubectl create -f mysql-rc.yaml
# 输出 replicationcontroller 'mysql' createdkubectl get rc
# -----------输出结果-----------------------
NAME DESIRED CURRENT READY AGE
mysql 1 1 0 12mK8s current 为0的问题 https://blog.csdn.net/a506681571/article/details/86087456 https://github.com/kubernetes/kubernetes/issues/11355#issuecomment-127378691 kubectl get pods
# -----------输出结果-----------------------
NAME READY STATUS RESTARTS AGE
mysql-0stfs 0/1 ContainerCreating 0 12mkubectl describe pod xxx# 删除POD
kubectl delete pod PODNAME --force --grace-period=0
# 删除NAMESPACE
kubectl delete namespace NAMESPACENAME --force --grace-period=0
|