Rancher部署k8s集群
rancher部署k8s集群
前提条件:
docker已经安装
一、Docker快速安装
sudo docker run -d --name=rancher2 --privileged --restart=unless-stopped -p 9080:80 -p 9443:443 rancher/rancher:v2.5.11
剩下步骤按要求一步一步来
二、部署私有网络下的LB开源方案metallb
在kubectl终端下执行一下命令
# 安装metallb.yaml
kubectl apply -f https://gitee.com/cyneck/metallb/raw/master/manifests/metallb.yaml
# 查看metallb-system命名空间是否生成
kubectl get all -n metallb-system
配置负载均衡私有网络下的地址池
kubectl apply -f - << EOF
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default # 默认命名空间上
protocol: layer2
addresses:
- 192.168.0.150-192.169.0.240 #自己的局域网地址池区间
EOF #输入EOF,输入文件结束
ingress
kubectl apply -f - << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-lb
namespace: default
spec:
selector:
matchLabels:
app: nginx-lb
replicas: 1
template:
metadata:
labels:
app: nginx-lb
spec:
containers:
- name: nginx-lb
image: nginx:1.7.9
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx-lb-svc
namespace: default
labels:
app: test-service-svc
spec:
selector:
app: nginx-lb
ports:
- protocol: TCP
name: http
port: 8090
targetPort: 80
type: LoadBalancer # 负载均衡形式
# 查看k8s集群下的service
kubectl get service