does anyone know how to enable serverside apply wi...
# kubernetes
v
does anyone know how to enable serverside apply with
@pulumi/eks
?
s
You’d use server-side apply with the Kubernetes provider after you use the EKS provider to stand up your cluster. More details/examples can be found here: https://www.pulumi.com/registry/packages/kubernetes/how-to-guides/managing-resources-with-server-side-apply/
v
Yeah i managed to get it working. now i am stuck with patching the coredns
Copy code
const provider = new k8s.Provider(`${this.clusterName}-k8s-provider`, {
            kubeconfig: this.cluster.kubeconfig,
            enableServerSideApply: true
        }, { provider: this.provider })

        return new k8s.apps.v1.DeploymentPatch(`${this.clusterName}-coredns-deployment-patch`, {
            metadata: {
                annotations: {
                    "<http://pulumi.com/patchForce|pulumi.com/patchForce>": "true",
                },
                name: 'coredns',
            },
            spec: {
                template: {
                    spec: {
                        affinity: {
                            podAffinity: {
                                preferredDuringSchedulingIgnoredDuringExecution: [{
                                    weight: 100,
                                    podAffinityTerm: {
                                        topologyKey: '<http://kubernetes.io/hostname|kubernetes.io/hostname>',
                                        labelSelector: {
                                            matchExpressions: [{
                                                key: 'k8s-app',
                                                operator: 'In',
                                                values: ['kube-dns']
                                            }]
                                        }
                                    }

                                }]
                            }
                        }
                    }
                }
            }
        }, { provider: provider, parent: this.cluster.provider })
Copy code
error: resource default/coredns was not successfully created by the Kubernetes API server : Deployment.apps "coredns" is invalid
: [spec.selector: Required value, spec.template.metadata.labels: Invalid value: map[string]string(nil): `selector` does not match te
mplate `labels`, spec.template.spec.containers: Required value]
s
For backward compatibility reasons, your deployment may be called “kube-dns” (even though it’s CoreDNS). I’d verify with
kubectl
, if at all possible.
v
Copy code
kd deployment -n kube-system coredns
Name:                   coredns
Namespace:              kube-system
CreationTimestamp:      Tue, 06 Sep 2022 03:51:27 +0600
Labels:                 <http://eks.amazonaws.com/component=coredns|eks.amazonaws.com/component=coredns>
                        k8s-app=kube-dns
                        <http://kubernetes.io/name=CoreDNS|kubernetes.io/name=CoreDNS>
Annotations:            <http://deployment.kubernetes.io/revision|deployment.kubernetes.io/revision>: 3
Selector:               <http://eks.amazonaws.com/component=coredns,k8s-app=kube-dns|eks.amazonaws.com/component=coredns,k8s-app=kube-dns>
Replicas:               2 desired | 2 updated | 2 total | 2 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  1 max unavailable, 25% max surge
Pod Template:
  Labels:           <http://eks.amazonaws.com/component=coredns|eks.amazonaws.com/component=coredns>
                    k8s-app=kube-dns
  Annotations:      <http://eks.amazonaws.com/compute-type|eks.amazonaws.com/compute-type>: ec2
                    <http://kubectl.kubernetes.io/restartedAt|kubectl.kubernetes.io/restartedAt>: 2022-09-07T02:02:37+06:00
  Service Account:  coredns
  Containers:
   coredns:
    Image:       <http://602401143452.dkr.ecr.ap-southeast-1.amazonaws.com/eks/coredns:v1.8.7-eksbuild.2|602401143452.dkr.ecr.ap-southeast-1.amazonaws.com/eks/coredns:v1.8.7-eksbuild.2>
    Ports:       53/UDP, 53/TCP, 9153/TCP
    Host Ports:  0/UDP, 0/TCP, 0/TCP
    Args:
      -conf
      /etc/coredns/Corefile
    Limits:
      memory:  170Mi
    Requests:
      cpu:        100m
      memory:     70Mi
    Liveness:     http-get http://:8080/health delay=60s timeout=5s period=10s #success=1 #failure=5
    Readiness:    http-get http://:8080/health delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:  <none>
    Mounts:
      /etc/coredns from config-volume (ro)
      /tmp from tmp (rw)
  Volumes:
   tmp:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
   config-volume:
    Type:               ConfigMap (a volume populated by a ConfigMap)
    Name:               coredns
    Optional:           false
  Priority Class Name:  system-cluster-critical
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   coredns-8665656d55 (2/2 replicas created)
Events:          <none>
this is what coredns deployment looks like
got it working. thank you 🙂
s
And what was the resolution to the issue you were facing?
v
the issue still exists. I contacted AWS support and they are still looking into it
i had a call for 3 hours with them debugging the issue
s
Sorry, I meant the issue you were running into with the CoreDNS patch. Did you get that working?
v
yes thank you 🙂
Copy code
patchCoreDns() {
        const provider = new k8s.Provider(`${this.clusterName}-k8s-provider`, {
            kubeconfig: this.cluster.kubeconfig,
            enableServerSideApply: true
        }, { provider: this.provider })

        return new k8s.apps.v1.DeploymentPatch(`${this.clusterName}-coredns-deployment-patch`, {
            metadata: {
                annotations: {
                    "<http://pulumi.com/patchForce|pulumi.com/patchForce>": "true",
                },
                name: 'coredns',
                namespace: 'kube-system',
            },
            spec: {
                selector: {
                    matchLabels: {
                        '<http://eks.amazonaws.com/component|eks.amazonaws.com/component>': 'coredns',
                        'k8s-app': 'kube-dns',
                    }
                },
                template: {
                    spec: {
                        affinity: {
                            podAffinity: {
                                preferredDuringSchedulingIgnoredDuringExecution: [{
                                    weight: 100,
                                    podAffinityTerm: {
                                        topologyKey: '<http://kubernetes.io/hostname|kubernetes.io/hostname>',
                                        labelSelector: {
                                            matchExpressions: [{
                                                key: 'k8s-app',
                                                operator: 'In',
                                                values: ['kube-dns']
                                            }]
                                        }
                                    }

                                }]
                            }
                        }
                    }
                }
            }
        }, { provider: provider, parent: this.cluster.provider })
    }
this is what its looks like 🙂
s
👍🏻