其他分享
首页 > 其他分享> > consul部署(k8s部署方式)

consul部署(k8s部署方式)

作者:互联网

这里我们使用helm进行部署

1.下载helm

wget https://get.helm.sh/helm-v3.9.0-linux-amd64.tar.gz

2.配helm的repo源

helm repo add hashicorp https://helm.releases.hashicorp.com

3.编写consul的config.yml文件

global:
  name: consul
# Configure your Consul servers in this section.
server:
  # Specify three servers that wait until all are healthy to bootstrap the Consul cluster.
  replicas: 3
  # Specify the resources that servers request for placement. These values will serve a large environment.
  storage: '10Gi'
  #storageClass: "nfs-sc"   #如配置了SC则将这个打开
  securityContext: # 服务器 Pod 的安全上下文,以 root 用户运行
    fsGroup: 2000
    runAsGroup: 2000
    runAsNonRoot: false
    runAsUser: 0
  resources:
    requests:
      memory: '512Mi'
      cpu: '0.5'
    limits:
      memory: '1Gi'
      cpu: '1'
# Configure Consul clients in this section
client:
  # Specify the resources that clients request for deployment.
  resources:
    requests:
      memory: '256Mi'
      cpu: '0.5'
    limits:
      memory: '512Gi'
      cpu: '1'
# Enable and configure the Consul UI.
ui:
  enabled: true

4.开始安装consul

helm install consul hashicorp/consul --values config.yaml --create-namespace --namespace consul --version "0.43.0"

5.如果集群没有配置SC则会发现POD一直处于pending的情况

[root@master1 consul]# kubectl get po -n consul 
NAME                  READY   STATUS    RESTARTS   AGE
consul-client-bjzvn   0/1     Running   0          110s
consul-client-dlr7n   0/1     Running   0          110s
consul-client-rkdtg   0/1     Running   0          110s
consul-server-0       0/1     Pending   0          110s
consul-server-1       0/1     Pending   0          110s
consul-server-2       0/1     Pending   0          110s
[root@master1 consul]# kubectl get pvc -n consul 
NAME                          STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
data-consul-consul-server-0   Pending                                                     2m16s
data-consul-consul-server-1   Pending                                                     2m16s
data-consul-consul-server-2   Pending                                                     2m16s
因为没有pv创建
[root@master1 consul]# kubectl get pv -n consul 
No resources found

出现上述情况则自己挂载好nfs创建pv就行

[root@master1 consul]# cat consul-pv.yaml 
apiVersion: v1
kind: PersistentVolume
metadata:
  name: data-consul-consul-server-0
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  nfs:
    path: /pvdata/consul0
    server: 172.16.149.202
可以参考以上模板

如果有sc的同学则删掉helm部署在congfig.yaml文件上打开sc改为自己sc的名字即可

标签:部署,consul,resources,server,110s,helm,k8s,Pending
来源: https://www.cnblogs.com/zjl-throb/p/16381982.html