-
Notifications
You must be signed in to change notification settings - Fork 143
Bug 1912888: Add recycler pod template as a ConfigMap #488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| namespace: openshift-kube-controller-manager | ||
| name: recycler-config | ||
| data: | ||
| recycler-pod.yaml: | | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: recycler-pod | ||
| namespace: openshift-infra | ||
| spec: | ||
| activeDeadlineSeconds: 60 | ||
| restartPolicy: Never | ||
| serviceAccountName: pv-recycler-controller | ||
| containers: | ||
| - name: recycler-container | ||
| image: "${TOOLS_IMAGE}" | ||
| command: | ||
| - "/bin/bash" | ||
| args: | ||
| - "-c" | ||
| - "test -e /scrub && rm -rf /scrub/..?* /scrub/.[!.]* /scrub/* && test -z \"$(ls -A /scrub)\" || exit 1" | ||
| volumeMounts: | ||
| - mountPath: /scrub | ||
| name: vol | ||
| securityContext: | ||
| runAsUser: 0 | ||
| volumes: | ||
| - name: vol |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,8 @@ spec: | |
| value: docker.io/openshift/origin-cluster-kube-controller-manager-operator:v4.0 | ||
| - name: CLUSTER_POLICY_CONTROLLER_IMAGE | ||
| value: quay.io/openshift/origin-cluster-policy-controller:v4.3 | ||
| - name: TOOLS_IMAGE | ||
| value: quay.io/openshift/origin-tools:latest | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This value is a placeholder for replacement mapped by https://github.com/openshift/cluster-kube-controller-manager-operator/blob/master/manifests/image-references. We need to add the tools image to that
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
| - name: OPERATOR_IMAGE_VERSION | ||
| value: "0.0.1-snapshot" | ||
| - name: OPERAND_IMAGE_VERSION | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,7 @@ spec: | |
| from: | ||
| kind: DockerImage | ||
| name: quay.io/openshift/origin-cluster-policy-controller:v4.3 | ||
| - name: tools # owned by storage team/fbertina@redhat.com | ||
| from: | ||
| kind: DockerImage | ||
| name: quay.io/openshift/origin-tools:latest | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there any harm in using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the release image building process will replace this image pull path with the |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ type TargetConfigController struct { | |
| targetImagePullSpec string | ||
| operatorImagePullSpec string | ||
| clusterPolicyControllerPullSpec string | ||
| toolsImagePullSpec string | ||
|
|
||
| operatorClient v1helpers.StaticPodOperatorClient | ||
|
|
||
|
|
@@ -68,7 +69,7 @@ type TargetConfigController struct { | |
|
|
||
| func NewTargetConfigController( | ||
| ctx context.Context, | ||
| targetImagePullSpec, operatorImagePullSpec, clusterPolicyControllerPullSpec string, | ||
| targetImagePullSpec, operatorImagePullSpec, clusterPolicyControllerPullSpec, toolsImagePullSpec string, | ||
| kubeInformersForNamespaces v1helpers.KubeInformersForNamespaces, | ||
| operatorClient v1helpers.StaticPodOperatorClient, | ||
| kubeClient kubernetes.Interface, | ||
|
|
@@ -80,6 +81,7 @@ func NewTargetConfigController( | |
| targetImagePullSpec: targetImagePullSpec, | ||
| operatorImagePullSpec: operatorImagePullSpec, | ||
| clusterPolicyControllerPullSpec: clusterPolicyControllerPullSpec, | ||
| toolsImagePullSpec: toolsImagePullSpec, | ||
|
|
||
| configMapLister: kubeInformersForNamespaces.ConfigMapLister(), | ||
| secretLister: kubeInformersForNamespaces.SecretLister(), | ||
|
|
@@ -196,6 +198,10 @@ func createTargetConfigController(ctx context.Context, c TargetConfigController, | |
| if err != nil { | ||
| errors = append(errors, fmt.Errorf("%q: %v", "configmap/cluster-policy-controller-config", err)) | ||
| } | ||
| _, _, err = manageRecycler(ctx, c.kubeClient.CoreV1(), recorder, c.toolsImagePullSpec) | ||
| if err != nil { | ||
| errors = append(errors, fmt.Errorf("%q: %v", "configmap/recycler-config", err)) | ||
| } | ||
| _, _, err = ManageCSRIntermediateCABundle(ctx, c.secretLister, c.kubeClient.CoreV1(), recorder) | ||
| if err != nil { | ||
| errors = append(errors, fmt.Errorf("%q: %v", "configmap/csr-intermediate-ca", err)) | ||
|
|
@@ -404,6 +410,19 @@ func manageControllerManagerKubeconfig(ctx context.Context, client corev1client. | |
| return resourceapply.ApplyConfigMap(client, recorder, requiredCM) | ||
| } | ||
|
|
||
| // manageRecycler applies a ConfigMap containing the recycler config. | ||
| // Owned by storage team/fbertina@redhat.com. | ||
| func manageRecycler(ctx context.Context, configMapsGetter corev1client.ConfigMapsGetter, recorder events.Recorder, imagePullSpec string) (*corev1.ConfigMap, bool, error) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keep a storage team indication and name here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| cmString := string(v411_00_assets.MustAsset("v4.1.0/kube-controller-manager/recycler-cm.yaml")) | ||
| for pattern, value := range map[string]string{ | ||
| "${TOOLS_IMAGE}": imagePullSpec, | ||
| } { | ||
| cmString = strings.ReplaceAll(cmString, pattern, value) | ||
| } | ||
| requiredCM := resourceread.ReadConfigMapV1OrDie([]byte(cmString)) | ||
| return resourceapply.ApplyConfigMap(configMapsGetter, recorder, requiredCM) | ||
| } | ||
|
|
||
| func managePod(ctx context.Context, configMapsGetter corev1client.ConfigMapsGetter, secretsGetter corev1client.SecretsGetter, recorder events.Recorder, operatorSpec *operatorv1.StaticPodOperatorSpec, imagePullSpec, operatorImagePullSpec, clusterPolicyControllerPullSpec string, addServingServiceCAToTokenSecrets bool) (*corev1.ConfigMap, bool, error) { | ||
| required := resourceread.ReadPodV1OrDie(v411_00_assets.MustAsset("v4.1.0/kube-controller-manager/pod.yaml")) | ||
| // TODO: If the image pull spec is not specified, the "${IMAGE}" will be used as value and the pod will fail to start. | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep a storage team indication and name here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done