单节点安装k8s
1、内网系统中建议关闭防火墙服务:# systemctl disable firewalld# systemctl stop firewalld2、安装etcd和Kubernetes (自动安装Docker)# yum install -y etcd kubernetes3、修改两个配置文件# vi /etc/sysconfig/docker// 将OPTIONS设置为:OP...
1、内网系统中建议关闭防火墙服务:
# systemctl disable firewalld
# systemctl stop firewalld
2、安装etcd和Kubernetes (自动安装Docker)
# yum install -y etcd kubernetes
3、修改两个配置文件
# vi /etc/sysconfig/docker
// 将OPTIONS设置为:OPTIONS='--selinux-enabled=false --insecure-registry gcr.io'
# vi /etc/kubernetes/apiserver
// 将 --admission_control 参数中的 ServiceAccount 删除
4、按顺序启动如下服务:
# 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
5、执行
rpm2cpio /mnt/Packages/python-rhsm-certificates-1.17.9-1.el7.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem
至此,一个单机版的Kubernetes集群环境已经安装完成
创建pod : nginx-pod.yaml
kubectl create -f nginx-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
name: nginx-pod
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
查看pod的状态
kubectl get pods
创建replicationController : nginx-rc.yaml
kubectl create -f nginx-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: nginx-rc
spec:
replicas: 1
selector:
name: nginx-pod
template:
metadata:
labels:
name: nginx-pod
spec:
containers:
- name: nginx-pod
image: nginx
ports:
- containerPort: 80
查看rc状态
kubectl get rc
创建service : nginx-service.yaml
kubectl create -f nginx-service.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: NodePort
ports:
- port: 80
nodePort: 30001
selector:
name: nginx-pod
查看service状态
kubectl get service
测试发布的nginx服务
使用其他机器的浏览器访问node1机器的30001端口
转载于:https://blog.51cto.com/204222/2156209
更多推荐
所有评论(0)