一、快速入门 1、关闭防火墙 systemctl disable firewalld systemctl stop firewalld 2、安装etcd和kubernetes软件 yum update yum install -y etcd kubernetes 3、启动服务 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 4、配置 A、tomcat配置 a、mkdir /usr/local/k8s b、cd /usr/local/k8s c、vim mytomcat.rc.yaml d、kubectl create -f mytomcat.rc.yaml e、vim mytomcat.svc.yaml f、kubectl create -f mytomcat.svc.yaml g、kubectl get pods h、kubectl get svc 5、问题解决 A、kubectl get pods(ContainerCreating问题解决) kubectl describe pod mytomcat(查看出错信息) yum -y install *rhsm* wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm rpm2cpio python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest B、kubectl get pods(No resources found问题解决) vim /etc/kubernetes/apiserver KUBE_ADMISSION_CONTROL删除ServiceAccount,选项 systemctl restart kube-apiserver C、外部网无法访问 vim /etc/sysctl.conf net.ipv4.ip_forward=1(文件末尾添加参数) cd /usr/local/k8s kubectl replace -f mytomcat.rc.yaml kubectl delete svc --all kubectl create -f mytomcat.svc.yaml iptables -P FORWARD ACCEPT 备注: 1、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:8-jre8 ports: - containerPort: 8080 2、mytomcat.svc.yaml apiVersion: v1 kind: Service metadata: name: mytomcat spec: type: NodePort ports: - port: 8080 nodePort: 30001 selector: app: mytomcat