My coredns in k8s cluster is v1.3.1.And I want to config it visiting kube-apiserver with static token. For example,my token is "token4K8sSecure".Ant I tried config coredns kubenernetes plugin with the configuration below.But it does not work.
apiVersion: v1
data:
Corefile: |
.:53 {
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
**endpoint https://100.6.0.20:6443
kubeconfig token token4K8sSecure**
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
prometheus :9153
forward . /etc/resolv.conf
cache 30
loop
reload
loadbalance
}
kind: ConfigMap
metadata:
creationTimestamp: "2019-11-19T08:55:08Z"
name: coredns
namespace: kube-system
resourceVersion: "452688"
selfLink: /api/v1/namespaces/kube-system/configmaps/coredns
uid: 449a38b9-1678-4c66-b1e8-96b5c273ad3d
Output: [root@a2 Matrix-V500R002B01D001]# kubectl logs coredns-7c4665f97b-nh2wj -n kube-system plugin/kubernetes: stat token: no such file or directory
welcome to StackOverflow.
You can - instead of using a Kubernetes Token - you can use Client Certificates like so:
tls <PATH_TO_CERT> <PATH_TO_KEY> <PATH_TO_CACERT>
If you don't want to use TLS Certificates you can specify a File as the kubeconfig
, with version 1.2.2 CoreDNS introduced the possibility that you can use a File from which CoreDNS loads the Context:
kubeconfig /path/to/token token
Mount the token into the Container and add the Path to the Config and it should work.