Skip to content

Commit d1f25ec

Browse files
Mikalai Radchukci-robot
authored andcommitted
UPSTREAM: <carry>: Add global-pull-secret flag
Pass global-pull-secret to the manager container. Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent 8878255 commit d1f25ec

File tree

30 files changed

+127
-27
lines changed

30 files changed

+127
-27
lines changed

openshift/generate-manifests.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ IMAGE_MAPPINGS[kube-rbac-proxy]='${KUBE_RBAC_PROXY_IMAGE}'
2020
# shellcheck disable=SC2016
2121
IMAGE_MAPPINGS[manager]='${OPERATOR_CONTROLLER_IMAGE}'
2222

23+
# This is a mapping of catalogd flag names to values. For example, given a deployment with a container
24+
# named "manager" and arguments:
25+
# args:
26+
# - --flagname=one
27+
# and an entry to the FLAG_MAPPINGS of FLAG_MAPPINGS[flagname]='two', the argument will be updated to:
28+
# args:
29+
# - --flagname=two
30+
#
31+
# If the flag doesn't already exist - it will be appended to the list.
32+
declare -A FLAG_MAPPINGS
33+
# shellcheck disable=SC2016
34+
FLAG_MAPPINGS[global-pull-secret]="openshift-config/pull-secret"
35+
2336
##################################################
2437
# You shouldn't need to change anything below here
2538
##################################################
@@ -60,6 +73,17 @@ for container_name in "${!IMAGE_MAPPINGS[@]}"; do
6073
$YQ -i 'select(.kind == "Namespace").metadata.annotations += {"workload.openshift.io/allowed": "management"}' "$TMP_KUSTOMIZE_OUTPUT"
6174
done
6275

76+
# Loop through any flag updates that need to be made to the manager container
77+
for flag_name in "${!FLAG_MAPPINGS[@]}"; do
78+
flagval="${FLAG_MAPPINGS[$flag_name]}"
79+
80+
# First, update the flag if it exists
81+
$YQ -i "(select(.kind == \"Deployment\") | .spec.template.spec.containers[] | select(.name == \"manager\") | .args[] | select(. | contains(\"--$flag_name=\")) | .) = \"--$flag_name=$flagval\"" "$TMP_KUSTOMIZE_OUTPUT"
82+
83+
# Then, append the flag if it doesn't exist
84+
$YQ -i "(select(.kind == \"Deployment\") | .spec.template.spec.containers[] | select(.name == \"manager\") | .args) |= (select(.[] | contains(\"--$flag_name=\")) | .) // . + [\"--$flag_name=$flagval\"]" "$TMP_KUSTOMIZE_OUTPUT"
85+
done
86+
6387
# Use yq to split the single yaml file into 1 per document.
6488
# Naming convention: $index-$kind-$namespace-$name. If $namespace is empty, just use the empty string.
6589
(
@@ -103,4 +127,3 @@ cp "$TMP_MANIFEST_DIR"/* "$MANIFEST_DIR"/
103127
fi
104128
done
105129
)
106-
Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
1-
# Adds namespace to all resources.
2-
namespace: OPENSHIFT-NAMESPACE
3-
41
namePrefix: operator-controller-
52

63
resources:
7-
- resources/ca_configmap.yaml
8-
- ../../../../config/base/crd
9-
- ../../../../config/base/rbac
10-
- ../../../../config/base/manager
11-
12-
patches:
13-
- target:
14-
kind: ClusterRole
15-
name: manager-role
16-
path: patches/manager_role.yaml
17-
- target:
18-
kind: Deployment
19-
name: controller-manager
20-
path: patches/manager_deployment_ca.yaml
21-
- target:
22-
kind: Deployment
23-
name: controller-manager
24-
path: patches/manager_deployment_mount_etc_containers.yaml
25-
- target:
26-
kind: Deployment
27-
name: controller-manager
28-
path: patches/manager_deployment_log_verbosity.yaml
29-
- path: patches/manager_namespace_privileged.yaml
4+
- olmv1-ns
5+
- openshift-config
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Adds namespace to all resources.
2+
namespace: OPENSHIFT-NAMESPACE
3+
4+
resources:
5+
- resources/ca_configmap.yaml
6+
- ../../../../../config/base/crd
7+
- ../../../../../config/base/rbac
8+
- ../../../../../config/base/manager
9+
10+
patches:
11+
- target:
12+
kind: ClusterRole
13+
name: manager-role
14+
path: patches/manager_role.yaml
15+
- target:
16+
kind: Deployment
17+
name: controller-manager
18+
path: patches/manager_deployment_ca.yaml
19+
- target:
20+
kind: Deployment
21+
name: controller-manager
22+
path: patches/manager_deployment_mount_etc_containers.yaml
23+
- target:
24+
kind: Deployment
25+
name: controller-manager
26+
path: patches/manager_deployment_log_verbosity.yaml
27+
- path: patches/manager_namespace_privileged.yaml
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Adds namespace to all resources.
2+
namespace: openshift-config
3+
4+
resources:
5+
- rbac/operator-controller_manager_role.yaml
6+
- rbac/operator-controller_manager_role_binding.yaml
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# permissions to do leader election.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: Role
4+
metadata:
5+
labels:
6+
app.kubernetes.io/part-of: olm
7+
app.kubernetes.io/name: catalogd
8+
name: manager-role
9+
rules:
10+
- apiGroups:
11+
- ""
12+
resources:
13+
- secrets
14+
verbs:
15+
- get
16+
- list
17+
- watch
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: RoleBinding
3+
metadata:
4+
labels:
5+
app.kubernetes.io/part-of: olm
6+
app.kubernetes.io/name: catalogd
7+
name: manager-rolebinding
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: Role
11+
name: manager-role
12+
subjects:
13+
- kind: ServiceAccount
14+
name: controller-manager
15+
namespace: OPENSHIFT-NAMESPACE
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: Role
4+
metadata:
5+
labels:
6+
app.kubernetes.io/name: catalogd
7+
app.kubernetes.io/part-of: olm
8+
name: operator-controller-manager-role
9+
namespace: openshift-config
10+
rules:
11+
- apiGroups:
12+
- ""
13+
resources:
14+
- secrets
15+
verbs:
16+
- get
17+
- list
18+
- watch
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: RoleBinding
4+
metadata:
5+
labels:
6+
app.kubernetes.io/name: catalogd
7+
app.kubernetes.io/part-of: olm
8+
name: operator-controller-manager-rolebinding
9+
namespace: openshift-config
10+
roleRef:
11+
apiGroup: rbac.authorization.k8s.io
12+
kind: Role
13+
name: operator-controller-manager-role
14+
subjects:
15+
- kind: ServiceAccount
16+
name: operator-controller-controller-manager
17+
namespace: openshift-operator-controller
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ spec:
4545
- --leader-elect
4646
- --ca-certs-dir=/var/certs
4747
- --v=${LOG_VERBOSITY}
48+
- --global-pull-secret=openshift-config/pull-secret
4849
command:
4950
- /operator-controller
5051
image: ${OPERATOR_CONTROLLER_IMAGE}

0 commit comments

Comments
 (0)