Skip to content

Instantly share code, notes, and snippets.

@lauralorenz
Created June 23, 2022 00:00
Show Gist options
  • Save lauralorenz/b40fd12a944c12068213ce85f8a04e68 to your computer and use it in GitHub Desktop.
Save lauralorenz/b40fd12a944c12068213ce85f8a04e68 to your computer and use it in GitHub Desktop.
CoreDNS multicluster plugin manual testing

To check that the plugin builds with the current version of coredns

  1. Ran local kind cluster with the ServiceImport CRD installed from the MCS API repo.
  2. Built local docker image against coredns/Dockerfile of latest coredns master commit c9eedcb, with multicluster plugin installed via refrencing it in coredns/plugin.cfg.
    docker build $MYDEVHOME/coredns/Dockerfile -t coredns-193-withmc
    
  3. Uploaded local image to kind cluster (did you know you needed to do that? I didn't. See KiND - How I Wasted a Day Loading Local Docker Images by Ivan Velichko)
    kind load docker-image coredns-193-withmc:latest
    
  4. Patched coredns deployment in kind cluster based on directions from these deployment directions, short version below.
    lauralorenz@lauralorenz:coredns$ kubectl patch deployment coredns -n kube-system -p '{"spec":{"template":{"spec":{"containers":[{"name":"coredns", "image":"coredns-193-withmc:latest"}]}}}}'
    deployment.apps/coredns patched
    #
    # I also updated the coredns/kube-dns Configmap to actually configure multicluster plugin, see multicluster plugin README
    #
    
  5. Gave the coredns SA, now that I'm using a version with the multicluster plugin installed, RBAC privileges to the ServiceImport CRD.
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: system:coredns-multicluster
    rules:
    - apiGroups:
      - "multicluster.x-k8s.io"
      resources:
      - serviceimports
      verbs: ["*"]
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: system:coredns-multicluster
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: system:coredns-multicluster
    subjects:
    - kind: ServiceAccount
      name: coredns
      namespace: kube-system
    
  6. Confirmed coredns redeployed, logs were healthy using kubectl.

More steps when you want to check that the multicluster plugin does what you think it does

  1. Deployed a fake ServiceImport in demo namespace.
    apiVersion: multicluster.x-k8s.io/v1alpha1
    kind: ServiceImport
    metadata:
      name: myservice
      namespace: demo
    spec:
      type: ClusterSetIP
      ips:
      - 1.2.3.4
      ports:
      - port: 80
        protocol: TCP
    
  2. Deployed dnsutils pod in demo namespace.
    apiVersion: v1
    kind: Pod
    metadata:
     name: dnsutils
     namespace: demo
    spec:
     containers:
     - name: dnsutils
       image: k8s.gcr.io/e2e-test-images/jessie-dnsutils:1.3
       command:
         - sleep
         - "3600"
       imagePullPolicy: IfNotPresent
     restartPolicy: Always
    
  3. Used dnsutils pod to confirm that the DNS query for the serviceimport responds with the IP I set in the fake ServiceImport.
    lauralorenz@lauralorenz:multicluster$ kubectl exec -it dnsutils -n demo -- bash
    root@dnsutils:/# nslookup myservice.demo.svc.clusterset.local
    Server:         10.96.0.10
    Address:        10.96.0.10#53
    
    Name:   myservice.demo.svc.clusterset.local
    Address: 1.2.3.4
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment