kubernets 单节点安装

时间:2021-12-30 11:49:10

关闭防火墙和Selinux。

setenforce 0
systemctl stop firewalld
systemctl disable firewalld

配置EPEL源

 yum install epel-release

可以选择更换EPEL的源为清华大学的源镜像站。提高安装速度。(参考文档

安装

yum install etcd kubernetes

修改配置文件

1:修改/etc/sysconfig/docker,其中OPTIONS的内容设置为
OPTIONS='--selinux-enabled=false --insecure-registry gcy.io --log-driver=journald'
2:修改/etc/kubernetes/apiserver,把--admission_control参数中的ServiceAccount删除。
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"

安装顺序启动以下服务

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 systemctl enable etcd
systemctl enable docker
systemctl enable kube-apiserver
systemctl enable kube-controller-manager
systemctl enable kube-scheduler
systemctl enable kubelet
systemctl enable kube-proxy

报错

运行容器的时候,发现一直处于ContainerCreating状态,一是网络不通,二是没有找到证书文件
安装一下相关的包:
yum install *rhsm* -y
网络不通的情况下,就很麻烦了,我这里选择的是修改docker源
vim /etc/docker/daemon.json {
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}

MySQL RC.yaml配置文件

kuberctl create -f mysql-rc.yaml
kbuerctl get rc
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"

MySQL SVC.yaml文件

kuberctl create -f mysql-svc.yaml
kubectl get pods
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
ports:
- port: 3306
selector:
app: mysql