ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

consul部署(k8s部署方式)

2022-06-16 15:02:44  阅读:241  来源: 互联网

标签:部署 consul resources server 110s helm k8s Pending


这里我们使用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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有