安装

Nodelocal DNS Cache

脚本需要修改一下执行:

# Download and modify the NodeLocal DNS manifest

manifest=$(curl -sL https://raw.githubusercontent.com/kubernetes/kubernetes/master/cluster/addons/dns/nodelocaldns/nodelocaldns.yaml)

# Replace placeholders with actual values

manifest=$(echo "$manifest" | 
  sed -e 's/__PILLAR__DNS__DOMAIN__/cluster.local/g' |
  sed -e "s/__PILLAR__DNS_SERVER__/$(kubectl get service --namespace kube-system kube-dns -o jsonpath='{.spec.clusterIP}')/g" |
  sed -e 's/__PILLAR__LOCAL__DNS__/169.254.20.10/g')   


# Apply the modified manifest

kubectl apply -f - <<< "$manifest"