<p>Is there a way to configure kube-proxy in GKE?</p>

<p>I can see the pods creating from the daemonset, but I cannot see the daemonset itself.</p>

<p>Thanks for your help.</p>

matth3o
<p>kube-proxy pod in k8s (not only in GKE) is created as <a href="https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/" rel="nofollow noreferrer">Static Pod</a>.</p>
<p>Kubelet automatically creates so-called mirror pod on Kubernetes API server for each static pod, so the pods are visible there, but they cannot be controlled from the API server.<a href="https://unofficial-kubernetes.readthedocs.io/en/latest/concepts/cluster-administration/static-pod/" rel="nofollow noreferrer">2</a></p>
<p>That's why you cannot edit and configure it as a usual API object.</p>
<p>However, you can edit kube-proxy manifest on the nodes and kubelet applies a new configuration.
Static pod manifest located on each node in</p>
<blockquote>
<p>/etc/kubernetes/manifests//etc/kubernetes/manifests/kube-proxy.manifest</p>
</blockquote>
<p>You can ssh into node and manually change it but we can automate it using cilium approach for removing kube-proxy<a href="https://docs.cilium.io/en/v1.9/gettingstarted/kubeproxy-free/" rel="nofollow noreferrer">3</a> with DaemonSet and modify it a little bit<a href="https://tech.griphone.co.jp/2020/08/06/cilium-kube-proxy-replacement/" rel="nofollow noreferrer">4</a>.</p>
<pre><code>apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: kube-proxy-configurator
  namespace: kube-system
spec:
  selector:
    matchLabels:
      name: kube-proxy-configurator
  template:
    metadata:
      labels:
        name: kube-proxy-configurator
    spec:
      initContainers:
        - command:
            - /bin/sh
            - -c
            - |
              echo 'Changing kube-proxy iptables-min-sync-period'

              sed -i 's/iptables-min-sync-period=10s/iptables-min-sync-period=2s/g' /etc/kubernetes/manifests/kube-proxy.manifest

              echo 'All Done!'

          image: alpine:latest
          name: kube-proxy-configurator
          securityContext:
            privileged: true
          volumeMounts:
            - mountPath: /etc/kubernetes
              name: kubernetes-configs
      containers:
        - image: k8s.gcr.io/pause
          name: pause
      terminationGracePeriodSeconds: 0
      volumes:
        - hostPath:
            path: /etc/kubernetes
            type: Directory
          name: kubernetes-configs
</code></pre>
<p>Just apply it and kube-proxy configuration will be changed on each node (even on newly created by autoscaler).</p>
<pre><code>kubectl apply -f kube-proxy-configurator.yml
</code></pre>
