kuernetes 集群联邦 federation部署

本文详细介绍了如何在Kubernetes集群中配置DNS服务,包括安装etcd和coredns,以及通过helm进行部署。同时,文章还讲解了如何使用kubefed初始化主集群,并实现集群联邦,注册和验证集群的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

kubernetes集群配置

  • 安装helm
  • 可以通过pvc动态创建pv
  • kubectl 版本要求1.8或1.9

自定义DNS

安装etcd(for dns)

helm install --namespace my-namespace --name etcd-operator stable/etcd-operator
helm upgrade --namespace my-namespace --set cluster.enabled=true etcd-operator stable/etcd-operator

部署coredns

helm fetch stable/coredns

解压后修改values

isClusterService: false
plugins:
  kubernetes:
    enabled: false
  etcd:
    enabled: true
    zones:
    - "example.com."
    endpoint: "http://etcd-cluster.my-namespace:2379"

**zones 最后有个 . **

helm install --namespace my-namespace --name coredns -f Values.yaml stable/coredns

初始化主集群

获取kubefed

从github上下载 地址: https://github.com/kubernetes/federation/releases

coredns配置

cat coredns-provider.conf
[Global]
etcd-endpoints = http://etcd-cluster.my-namespace:2379
zones = example.com.

获取集群的连接信息

kubectl config get-contexts
CURRENT   NAME                     CLUSTER          AUTHINFO               NAMESPACE
*         fellowship               fellowship       fellowship
          node202.k8s.com          kubernetes       kubernetes-admin
          sjx.k8s.com              kubernetes-sjx   kubernetes-admin-sjx

部署federation

kubefed init fellowship \                                         #集群联邦的context name
    --host-cluster-context=node202.k8s.com \                      #主集群的context NAME
    --dns-provider="coredns" \                                    # DNS 服务提供商,还支持 aws-route53 或 google-clouddns
    --dns-zone-name="k8s.inspur.com." \                           #域名后缀,必须以. 结束
    --dns-provider-config="/root/coredns-provider.conf" \         #coredns 配置
    --apiserver-arg-overrides="--anonymous-auth=false,--v=4" \    # federation API server 自定义参数
    --api-server-service-type="NodePort" \                        #在自己的机器上需要用NodePort
    --etcd-pv-storage-class='ceph-rbd' \                          #sc
    --image='markdotsonrs/fcp-amd64:v1.9.0-alpha.3' \             #使用dockerhub上的镜像
    --etcd-image='s7799653/google-etcd'                           #使用dockerhub上的镜像

注册集群

kubefed join new  \                                       #自定义名称
    --host-cluster-context=node202.k8s.com \              #集群联邦所在集群的context
    --cluster-context=node202.k8s.com                     #要加入集群的context

验证

kubectl config use-context fellowship
kubectl get cluster
kubectl create ns default 
kubectl run nginx --image nginx --port 80 --replicas=4
kubectl get deploy
kubectl --context=node202.k8s.com get po -n default
kubectl --context=sjx.k8s.com get po -n default

参考

https://my.oschina.net/u/2306127/blog/1835623
https://kubernetes.io/docs/tasks/federation/set-up-cluster-federation-kubefed/
https://feisky.gitbooks.io/kubernetes/content/components/federation.html

Prometheus联邦集群部署文档 一、简介 Prometheus联邦集群可以实现多个Prometheus实例之间的数据共享和查询,解决了单个Prometheus实例面对大规模监控数据的性能瓶颈和数据管理问题。本文档将介绍如何部署Prometheus联邦集群。 二、前置条件 1.已经安装了Prometheus。 2.所有Prometheus实例的版本必须相同。 3.所有Prometheus实例的配置文件必须相同。 4.所有Prometheus实例的时间必须同步。 5.所有Prometheus实例的数据存储位置必须相同。 三、部署步骤 1.编辑Prometheus配置文件,添加联邦配置 在每个Prometheus实例的配置文件中添加如下配置: ``` remote_write: - url: "http://prometheus1.example.com:9090/api/v1/write" - url: "http://prometheus2.example.com:9090/api/v1/write" ``` 其中,url为其他Prometheus实例的remote_write地址。 2.重启Prometheus实例 在每个Prometheus实例上执行以下命令: ``` systemctl restart prometheus ``` 3.配置Prometheus实例的查询端点 在每个Prometheus实例的配置文件中添加如下配置: ``` remote_read: - url: "http://prometheus1.example.com:9090/api/v1/read" - url: "http://prometheus2.example.com:9090/api/v1/read" ``` 其中,url为其他Prometheus实例的remote_read地址。 4.重启Prometheus实例 在每个Prometheus实例上执行以下命令: ``` systemctl restart prometheus ``` 5.验证联邦集群配置 在每个Prometheus实例的Web界面上,点击“Status” => “Federation”,可以看到联邦集群的状态信息。 四、总结 通过以上步骤,可以创建Prometheus联邦集群,实现多个Prometheus实例之间的数据共享和查询。但需要注意的是,联邦集群配置的正确性和性能取决于网络和存储的性能,因此需要进行充分的测试和调优。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值