Skip to content

Commit 3151bd0

Browse files
committed
Changes to generate new OLM microshift manifests
This commit includes changes to the generate_crds_manifests.sh script to generate a new set of manifests with the required changes to work on microshift. Signed-off-by: Joaquim Moreno Prusi <[email protected]>
1 parent e98b8f0 commit 3151bd0

File tree

2 files changed

+55
-4
lines changed

2 files changed

+55
-4
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,14 @@ vendor:
142142
manifests: ## Generate manifests
143143
OLM_VERSION=$(OLM_VERSION) ./scripts/generate_crds_manifests.sh
144144

145+
.PHONY: microshift-manifests
146+
microshift-manifests: ## Generate manifests for microshift
147+
OLM_VERSION=$(OLM_VERSION) ./scripts/generate_crds_manifests.sh
148+
149+
145150
.PHONY: generate-manifests
146151
generate-manifests: OLM_VERSION=0.0.1-snapshot
147-
generate-manifests: manifests
152+
generate-manifests: manifests microshift-manifests
148153

149154
.PHONY: diff
150155
diff:

scripts/generate_crds_manifests.sh

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ YQ="go run ./vendor/github.com/mikefarah/yq/v3/"
1111
CONTROLLER_GEN="go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen"
1212
HELM="go run helm.sh/helm/v3/cmd/helm"
1313

14-
1514
ver=${OLM_VERSION:-"0.0.0-dev"}
1615
tmpdir="$(mktemp -p . -d 2>/dev/null || mktemp -d ./tmpdir.XXXXXXX)"
1716
chartdir="${tmpdir}/chart"
@@ -485,8 +484,6 @@ subjects:
485484
name: system:authenticated
486485
EOF
487486

488-
add_ibm_managed_cloud_annotations "${ROOT_DIR}/manifests"
489-
490487
find "${ROOT_DIR}/manifests" -type f -exec $SED -i "/^#/d" {} \;
491488
find "${ROOT_DIR}/manifests" -type f -exec $SED -i "1{/---/d}" {} \;
492489

@@ -497,3 +494,52 @@ find "${ROOT_DIR}/manifests" -type f -exec $SED -i "1{/---/d}" {} \;
497494
# namespaces enforce restricted PSA policies, so warnings and audits labels are not neccessary.
498495
${YQ} delete --inplace -d'*' manifests/0000_50_olm_00-namespace.yaml 'metadata.labels."pod-security.kubernetes.io/warn*"'
499496
${YQ} delete --inplace -d'*' manifests/0000_50_olm_00-namespace.yaml 'metadata.labels."pod-security.kubernetes.io/audit*"'
497+
498+
499+
# Let's copy all the manifests to a separate directory for microshift
500+
mkdir -p "${ROOT_DIR}/microshift-manifests/"
501+
rm -rf "${ROOT_DIR}/microshift-manifests/"*
502+
cp "${ROOT_DIR}"/manifests/* "${ROOT_DIR}/microshift-manifests/"
503+
504+
# Let's add the annotations for ibm-cloud-managed on the standard manifests
505+
# !! Order matters, as we don't need the IBM managed annotations on the microshift manifests.
506+
add_ibm_managed_cloud_annotations "${ROOT_DIR}/manifests"
507+
508+
# Let's generate the microshift-manifests.
509+
# There are some differences that we need to take care of:
510+
# - The manifests require a kustomization.yaml file
511+
# - We don't need the specific ibm-cloud-managed manifests
512+
# - We need to adapt some of the manifests to be compatible with microshift as there's no
513+
# ClusterVersion or ClusterOperator in microshift
514+
515+
# Create the kustomization file
516+
cat << EOF > "${ROOT_DIR}/microshift-manifests/kustomization.yaml"
517+
apiVersion: kustomize.config.k8s.io/v1beta1
518+
kind: Kustomization
519+
resources:
520+
EOF
521+
522+
# Now let's generate the kustomization.yaml file for microshift to pick up the manifests.
523+
microshift_manifests_files=$(find "${ROOT_DIR}/microshift-manifests" -type f -name "*.yaml")
524+
# filest to ignore, substring match.
525+
files_to_ignore=("ibm-cloud-managed.yaml" "kustomization.yaml" "psm-operator")
526+
527+
# Add all the manifests files to the kustomization file while ignoring the files in the files_to_ignore list
528+
for file in ${microshift_manifests_files}; do
529+
for file_to_ignore in ${files_to_ignore[@]}; do
530+
if [[ "${file}" =~ "${file_to_ignore}" ]]; then
531+
continue 2
532+
fi
533+
done
534+
echo " - $(realpath --relative-to "${ROOT_DIR}/microshift-manifests" "${file}")" >> "${ROOT_DIR}/microshift-manifests/kustomization.yaml"
535+
done
536+
537+
# Now we need to get rid of these args from the olm-operator deployment:
538+
#
539+
# - --writeStatusName
540+
# - operator-lifecycle-manager
541+
# - --writePackageServerStatusName
542+
# - operator-lifecycle-manager-packageserver
543+
#
544+
${SED} -i '/- --writeStatusName/,+3d' ${ROOT_DIR}/microshift-manifests/0000_50_olm_07-olm-operator.deployment.yaml
545+

0 commit comments

Comments
 (0)