标签:clu als conf secure bsp 配置文件 str nal https
安装kubernetes
准备一台centos7
1) 关闭firewalld 和 selinux
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
2)安装etcd和kubernetes
yum install -y etcd kubernetes
3)修改配置文件
vi /etc/sysconfig/docker
将--selinux-enabled 改为 --selinux-enabled=false --insecure-registry gcr.io
vi /etc/kubernetes/apiserver
把--admission_control参数中的ServiceAccount删除
4)准备工作
yum install python-rhsm-certificates
如果提示python-rhsm-certificates-1.19.10-1.el7_4.x86_64 被已安装的 subscription-manager-rhsm-certificates-
1.20.11-1.el7.centos.x86_64 取代
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/r hsm/ca/redhat-
uep.pem > /etc/r hsm/ca/redhat-uep.pem
配置docker加速器
vi /etc/docker/daemon.json//加入如下内容
{
"registry-mirrors": ["https://dhq9bx4f.mirror.aliyuncs.com"]
}
5)按顺序启动所有服务
for s in etcd docker kube-apiserver kube-controller-manager kube-scheduler kubelet kube-proxy
do
systemctl start $s
done
6)创建一个rc文件
vim mysql-rc.yaml
apiVersion: v1 kind: ReplicationController metadata: name: mysql spec: replicas: 1 selector: app: mysql template: metadata: labels: app: mysql spec: containers: - name: mysql image: mysql:5.6 ports: - containerPort: 3306 env: - name: MYSQL_ROOT_PASSWORD value: "123456"
docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
docker pull mysql:5.6
kubectl create -f mysql-rc.yaml
kubectl get rc
kubectl get pods
7)创建一个svc文件
vim mysql-svc.yaml
apiVersion: v1 kind: Service metadata: name: mysql spec: ports: - port: 3306 selector: app: mysql
kubectl create -f mysql-svc.yaml
kubectl get svc
8)创建web rc文件
vim web-rc.yaml
kind: ReplicationController metadata: name: myweb spec: replicas: 1 selector: app: myweb template: metadata: labels: app: myweb spec: containers: - name: myweb image: kubeguide/tomcat-app:v1 ports: - containerPort: 8080 env: - name: MYSQL_SERVICE_HOST value: ‘10.254.170.174‘ #这里的IP需要通过kubectl get svc 查看mysql的cluster ip - name: MYSQL_SERVICE_PORT value: ‘3306‘
[root@weifeng04 ~]# kubectl get svc NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes 10.254.0.1 <none> 443/TCP 3d mysql 10.254.170.174 <none> 3306/TCP 3d
kubectl create -f web-rc.yaml
9)创建web svc文件
vim web-svc.yamly
kind: Service metadata: name: myweb spec: type: NodePort ports: - port: 8080 nodePort: 30001 selector: app: myweb
kubectl create -f web-svc.yaml
10)访问
iptables -P FORWARD ACCEPT
curl 本机ip:30001/demo/ 或浏览器
[root@weifeng04 ~]# curl 192.168.20.99:30001/demo/ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>HPE University Docker&Kubernetes Learning</title> </head> <body align="center"> <h2>Congratulations!!</h2> <br></br> <input type="button" value="Add..." onclick="location.href=‘input.html‘" > <br></br> <TABLE align="center" border="1" width="600px"> <TR>
标签:clu als conf secure bsp 配置文件 str nal https
原文地址:https://www.cnblogs.com/weifeng1463/p/9900304.html