platform9 / ssh-provider

SSH Machine Controller for the Cluster API
11 stars 4 forks source link

Omit fields in Kubelet and KubeProxy configuration that not given by the user or by ssh-provider (as a default value) #61

Open dlipovetsky opened 5 years ago

dlipovetsky commented 5 years ago

There are many properties that are being set that have no default. Their zero values are appearing in the marshalled struct. In all the cases I've checked, the upstream default (documented in the type definitions) is not the zero value.

Their presence is confusing in two ways: (1) neither the user nor ssh-provider set the values, and (2) the values will be ignored by kubelet and kube-proxy when they read their configuration.

The properties that are empty objects or have zero second durations should not be set at all:

  kubeProxy:
    clientConnection: {}
    configSyncPeriod: 0s
    conntrack: {}
    iptables:
      minSyncPeriod: 0s
      syncPeriod: 0s
    ipvs:
      minSyncPeriod: 0s
      syncPeriod: 0s
    mode: ""
    udpIdleTimeout: 0s
  kubeletConfiguration:
    authentication:
      anonymous: {}
      webhook:
        cacheTTL: 0s
      x509: {}
    authorization:
      webhook:
        cacheAuthorizedTTL: 0s
        cacheUnauthorizedTTL: 0s
    cpuManagerReconcilePeriod: 0s
    evictionHard:
      memory.available: 600Mi
      nodefs.available: 10%
    evictionPressureTransitionPeriod: 0s
    failSwapOn: false
    featureGates:
      ExperimentalCriticalPodAnnotation: true
    fileCheckFrequency: 0s
    httpCheckFrequency: 0s
    imageMinimumGCAge: 0s
    kubeAPIBurst: 40
    kubeAPIQPS: 20
    maxPods: 500
    nodeStatusUpdateFrequency: 0s
    runtimeRequestTimeout: 0s
    streamingConnectionIdleTimeout: 0s
    syncFrequency: 0s
    volumeStatsAggPeriod: 0s
dlipovetsky commented 5 years ago

Although this is a bug, it has no impact on the actual configuration. Both kubelet and kube-proxy interprets a field with a zero value (e.g. 0s for duration, or {} for a struct) as not being defined, and therefore sets its own default value.

For example, compare this excerpt of nodeadm configuration:

masterConfiguration:
  kubeProxy:
    clientConnection: {}
    configSyncPeriod: 0s
    conntrack: {}
    iptables:
      minSyncPeriod: 0s
      syncPeriod: 0s
    ipvs:
      minSyncPeriod: 0s
      syncPeriod: 0s
    mode: ""
    udpIdleTimeout: 0s

With the kube-proxy config map generated by kubeadm:

# /opt/bin/kubectl -n kube-system get cm kube-proxy -oyaml
apiVersion: v1
data:
  config.conf: |-
    apiVersion: kubeproxy.config.k8s.io/v1alpha1
    bindAddress: 0.0.0.0
    clientConnection:
      acceptContentTypes: ""
      burst: 10
      contentType: application/vnd.kubernetes.protobuf
      kubeconfig: /var/lib/kube-proxy/kubeconfig.conf
      qps: 5
    clusterCIDR: ""
    configSyncPeriod: 15m0s
    conntrack:
      max: null
      maxPerCore: 32768
      min: 131072
      tcpCloseWaitTimeout: 1h0m0s
      tcpEstablishedTimeout: 24h0m0s
    enableProfiling: false
    healthzBindAddress: 0.0.0.0:10256
    hostnameOverride: ""
    iptables:
      masqueradeAll: false
      masqueradeBit: 14
      minSyncPeriod: 0s
      syncPeriod: 30s
    ipvs:
      minSyncPeriod: 0s
      scheduler: ""
      syncPeriod: 30s
    kind: KubeProxyConfiguration
    metricsBindAddress: 127.0.0.1:10249
    mode: ""
    nodePortAddresses: null
    oomScoreAdj: -999
    portRange: ""
    resourceContainer: /kube-proxy
    udpIdleTimeout: 250ms
  kubeconfig.conf: |-
    apiVersion: v1
    kind: Config
    clusters:
    - cluster:
        certificate-authority: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
        server: https://10.105.16.229:6443
      name: default
    contexts:
    - context:
        cluster: default
        namespace: default
        user: default
      name: default
    current-context: default
    users:
    - name: default
      user:
        tokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
kind: ConfigMap
metadata:
  creationTimestamp: 2019-01-10T01:02:17Z
  labels:
    app: kube-proxy
  name: kube-proxy
  namespace: kube-system
  resourceVersion: "181"
  selfLink: /api/v1/namespaces/kube-system/configmaps/kube-proxy
  uid: 603493bb-1473-11e9-91ae-fa163e1a3380

Note that the values in the config map are not those given in the nodeadm config.