Skip to content

Commit

Permalink
WIP: Change YAML style of scheduler-kubeconfig from human to compact …
Browse files Browse the repository at this point in the history
…JSON

(This is currently a WIP PR suggestion)

# Background

The `scheduler-kubeconfig` configmap managed by this operator contains a
YAML formatted `kubeconfig` string. As part of a particular novel form
of OCP deployment (image based upgrade/installation), we have to
programmatically modify the `server:` entry in that kubeconfig. This is
easily done by parsing the YAML, editing the server entry and
serializing the YAML back into the configmap.

# Issue

Every YAML serializer has its own opinions of what YAML should look
like. When we perform the procedure described above, we get a kubeconfig
that's slightly different then what this operator outputs (different
indentation, different quoting decisions). As a result, it eventually
causes the kube-scheduler-operator to issue a new revision of the
scheduler. Rolling out the new revision takes a few minutes, which we
would prefer to avoid.

# Solution

In order to solve this we suggest the change in this commit which would
be to format this kubeconfig as unopinionated compact JSON as opposed to
human readable YAML

# Alternative solutions

We could have a textual "search-and-replace" for the `server:` entry in
our code, but we would prefer to do it right by properly parsing,
editing then serializing it.
  • Loading branch information
omertuc committed Dec 22, 2023
1 parent cb424ff commit dd6cc3c
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions bindata/assets/kube-scheduler/kubeconfig-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,4 @@ metadata:
name: scheduler-kubeconfig
namespace: openshift-kube-scheduler
data:
kubeconfig: |
apiVersion: v1
clusters:
- cluster:
certificate-authority: /etc/kubernetes/static-pod-resources/configmaps/serviceaccount-ca/ca-bundle.crt
server: $LB_INT_URL
name: lb-int
contexts:
- context:
cluster: lb-int
user: kube-scheduler
name: kube-scheduler
current-context: kube-scheduler
kind: Config
preferences: {}
users:
- name: kube-scheduler
user:
client-certificate: /etc/kubernetes/static-pod-certs/secrets/kube-scheduler-client-cert-key/tls.crt
client-key: /etc/kubernetes/static-pod-certs/secrets/kube-scheduler-client-cert-key/tls.key
kubeconfig: '{"apiVersion":"v1","clusters":[{"cluster":{"certificate-authority":"/etc/kubernetes/static-pod-resources/configmaps/serviceaccount-ca/ca-bundle.crt","server":"$LB_INT_URL"},"name":"lb-int"}],"contexts":[{"context":{"cluster":"lb-int","user":"kube-scheduler"},"name":"kube-scheduler"}],"current-context":"kube-scheduler","kind":"Config","preferences":{},"users":[{"name":"kube-scheduler","user":{"client-certificate":"/etc/kubernetes/static-pod-certs/secrets/kube-scheduler-client-cert-key/tls.crt","client-key":"/etc/kubernetes/static-pod-certs/secrets/kube-scheduler-client-cert-key/tls.key"}}]}'

0 comments on commit dd6cc3c

Please sign in to comment.