CentOS 7
1. 安装 etcd & kubernetes
yum -y install etcd kubernetes
2.所有防火墙与 SELinux 已关闭:
systemctl stop firewalld && systemctl disable firewalld
vi /etc/sysconfig/selinux
SELINUX=disabled
3. 启动相关服务
systemctl start docker
systemctl start kube-apiserver
systemctl start kube-controller-manager
systemctl start kube-scheduler
systemctl start kubelet
systemctl start kube-proxy
4. 准备文件
mytomcat-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: mytomcat
spec:
replicas: 2
selector:
app: mytomcat
template:
metadata:
labels:
app: mytomcat
spec:
containers:
- name: mytomcat
image: tomcat
ports:
- containerPort: 8080
mytomcat-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: mytomcat
spec:
type: NodePort
ports:
- port: 8080
nodePort: 30001
selector:
app: mytomcat
5. 启动
kubectl create -f mytomcat-rc.yaml
kubectl create -f mytomcat-svc.yaml
6.查看
kubectl get pods
kubectl get svc
kubectl get pods 获取不到问题解决:
vi /etc/kubernetes/spiserver
找到
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota"
去掉 ServiceAccount 并重启 apiserver 服务
systemctl restart kube-apiserver