跳过正文
  1. Posts/

k8s之coredns部署脚本

·96 字·1 分钟·
Kubehan
作者
Kubehan
云原生知识栈:深度解析容器技术、Kubernetes、Istio、DevOps 实践、Prometheus 监控、Envoy 代理、Golang 开发及云原生架构与微服务趋势的专业博客

需要注意脚本里面的IP地址的对应关系

yum -y install epel-release>&/dev/null
yum -y install jq>&/dev/null
kubectl delete serviceaccount coredns>&/dev/null
kubectl delete clusterrole.rbac.authorization.k8s.io system:coredns --namespace=kube-system>&/dev/null
kubectl delete clusterrolebinding.rbac.authorization.k8s.io system:coredns --namespace=kube-system>&/dev/null
kubectl delete configmap coredns --namespace=kube-system>&/dev/null
kubectl delete deployment.apps coredns --namespace=kube-system>&/dev/null
kubectl delete service kube-dns --namespace=kube-system>&/dev/null
bash modules/deploy_coredns.sh -r 10.0.0.0/24 -i 10.0.0.2 -d cluster.local -t modules/coredns.yaml | kubectl apply -f -

# If you deploy successfully. You can enter a container and you will see these:
# kubectl exec -it dns-tets-tools-6bf6db5c4f-nnp9p sh
# nslookup www.baidu.com
# Server:    10.0.0.2
# Address 1: 10.0.0.2 kube-dns.kube-system.svc.cluster.local
# Name:      www.baidu.com
# Address 1: 182.61.200.6
# Address 2: 182.61.200.7