Skip to content
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

Add support for deployment on community distro okd #648

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# general
SHELL := /bin/bash
OCP_RELEASE := $(shell cut -d '.' -f 1,2 <<< $(shell oc version -o json | jq -r .openshiftVersion))
OKD ?= false
OPERATOR_NAMESPACE ?= openstack-operators
NAMESPACE ?= openstack
PASSWORD ?= 12345678
Expand Down Expand Up @@ -1900,6 +1901,14 @@ nmstate: ## installs nmstate operator in the openshift-nmstate namespace
bash scripts/gen-namespace.sh
oc apply -f ${OUT}/${NAMESPACE}/namespace.yaml
sleep 2
ifeq ($(OKD), true)
bash scripts/gen-olm-nmstate-okd.sh
oc apply -f ${OPERATOR_DIR}
timeout ${TIMEOUT} bash -c "while ! (oc get deployments/nmstate-operator -n ${NAMESPACE}); do sleep 10; done"
oc wait deployments/nmstate-operator -n ${NAMESPACE} --for condition=Available --timeout=${TIMEOUT}
oc apply -f ${DEPLOY_DIR}
sleep 30
else
bash scripts/gen-olm-nmstate.sh
oc apply -f ${OPERATOR_DIR}
timeout ${TIMEOUT} bash -c "while ! (oc get deployments/nmstate-operator -n ${NAMESPACE}); do sleep 10; done"
Expand All @@ -1909,6 +1918,7 @@ nmstate: ## installs nmstate operator in the openshift-nmstate namespace
oc wait pod -n ${NAMESPACE} -l component=kubernetes-nmstate-handler --for condition=Ready --timeout=$(TIMEOUT)
timeout ${TIMEOUT} bash -c "while ! (oc get deployments/nmstate-webhook -n ${NAMESPACE}); do sleep 10; done"
oc wait deployments/nmstate-webhook -n ${NAMESPACE} --for condition=Available --timeout=${TIMEOUT}
endif

.PHONY: nncp
nncp: export INTERFACE=${NNCP_INTERFACE}
Expand Down Expand Up @@ -1981,8 +1991,18 @@ metallb: ## installs metallb operator in the metallb-system namespace
bash scripts/gen-namespace.sh
oc apply -f ${OUT}/${NAMESPACE}/namespace.yaml
sleep 2
ifeq ($(OKD), true)
bash scripts/gen-operatorshub-catalog.sh
oc apply -f ${OPERATOR_DIR}/operatorshub-catalog/
timeout ${TIMEOUT} bash -c "while ! (oc get packagemanifests metallb-operator --no-headers=true | grep metallb-operator); do sleep 10; done"
bash scripts/gen-olm-metallb-okd.sh
oc apply -f ${OPERATOR_DIR}
timeout ${TIMEOUT} bash -c "while ! (oc get deployment metallb-operator-controller-manager --no-headers=true -n ${NAMESPACE}| grep metallb-operator-controller-manager); do sleep 10; done"
oc apply -f ${OPERATOR_DIR}/patches
else
bash scripts/gen-olm-metallb.sh
oc apply -f ${OPERATOR_DIR}
endif
timeout ${TIMEOUT} bash -c "while ! (oc get pod --no-headers=true -l control-plane=controller-manager -n ${NAMESPACE}| grep metallb-operator-controller); do sleep 10; done"
oc wait pod -n ${NAMESPACE} --for condition=Ready -l control-plane=controller-manager --timeout=$(TIMEOUT)
timeout ${TIMEOUT} bash -c "while ! (oc get pod --no-headers=true -l component=webhook-server -n ${NAMESPACE}| grep metallb-operator-webhook); do sleep 10; done"
Expand Down Expand Up @@ -2175,6 +2195,17 @@ certmanager: export OPERATOR_NAMESPACE=$(if $(findstring 4.10,$(OCP_RELEASE)),op
certmanager: export CHANNEL=$(if $(findstring 4.10,$(OCP_RELEASE)),tech-preview,stable-v1.11)
certmanager: ## installs cert-manager operator in the cert-manager-operator namespace, cert-manager runs it cert-manager namespace
$(eval $(call vars,$@,cert-manager))
ifeq ($(OKD), true)
$(MAKE) operator_namespace OPERATOR_NAMESPACE=cert-manager
bash scripts/gen-olm-cert-manager-okd.sh
oc apply -f ${OPERATOR_DIR}
while ! (oc get pod --no-headers=true -l app=cainjector -n ${NAMESPACE} | grep "cert-manager-cainjector"); do sleep 10; done
oc wait pod -n ${NAMESPACE} -l app=cainjector --for condition=Ready --timeout=$(CERTMANAGER_TIMEOUT)
while ! (oc get pod --no-headers=true -l app=webhook -n ${NAMESPACE} | grep "cert-manager-webhook"); do sleep 10; done
oc wait pod -n ${NAMESPACE} -l app=webhook --for condition=Ready --timeout=$(CERTMANAGER_TIMEOUT)
while ! (oc get pod --no-headers=true -l app=cert-manager -n ${NAMESPACE} | grep "cert-manager"); do sleep 10; done
oc wait pod -n ${NAMESPACE} -l app=cert-manager --for condition=Ready --timeout=$(CERTMANAGER_TIMEOUT)
else
$(MAKE) operator_namespace
bash scripts/gen-olm-cert-manager.sh
oc apply -f ${OPERATOR_DIR}
Expand All @@ -2186,6 +2217,7 @@ certmanager: ## installs cert-manager operator in the cert-manager-operator name
oc wait pod -n ${NAMESPACE} -l app=webhook --for condition=Ready --timeout=$(CERTMANAGER_TIMEOUT)
while ! (oc get pod --no-headers=true -l app=cert-manager -n ${NAMESPACE} | grep "cert-manager"); do sleep 10; done
oc wait pod -n ${NAMESPACE} -l app=cert-manager --for condition=Ready --timeout=$(CERTMANAGER_TIMEOUT)
endif

.PHONY: certmanager_cleanup
certmanager_cleanup: export NAMESPACE=$(if $(findstring 4.10,$(OCP_RELEASE)),openshift-cert-manager,cert-manager)
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,11 @@ openstack network agent list
cd devsetup
make edpm_deploy_instance
```

## Deployment on OKD distro

To deploy operators in okd community distro add parameter OKD=true to the make commands.

```bash
make openstack OKD=true
```
70 changes: 70 additions & 0 deletions scripts/gen-olm-cert-manager-okd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash
#
# Copyright 2023 Red Hat Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -ex

if [ -z "${OPERATOR_DIR}" ]; then
echo "Please set OPERATOR_DIR"; exit 1
fi

if [ -z "${OPERATOR_NAMESPACE}" ]; then
echo "Please set OPERATOR_NAMESPACE"; exit 1
fi

if [ -z "${OCP_RELEASE}" ]; then
echo "Please set OCP_RELEASE"; exit 1
fi

if [ -z "${CHANNEL}" ]; then
echo "Please set CHANNEL"; exit 1
fi

if [ ! -d ${OPERATOR_DIR} ]; then
mkdir -p ${OPERATOR_DIR}
fi

echo OCP_RELEASE ${OCP_RELEASE}
echo OPERATOR_DIR ${OPERATOR_DIR}
echo OPERATOR_NAMESPACE ${OPERATOR_NAMESPACE}
echo CHANNEL ${CHANNEL}

cat > ${OPERATOR_DIR}/operatorgroup.yaml <<EOF_CAT
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
annotations:
olm.providedAPIs: CertManager.v1alpha1.operator.openshift.io,Certificate.v1.cert-manager.io,CertificateRequest.v1.cert-manager.io,Challenge.v1.acme.cert-manager.io,ClusterIssuer.v1.cert-manager.io,Issuer.v1.cert-manager.io,Order.v1.acme.cert-manager.io
generateName: cert-manager-operator-
name: cert-manager-operator-bccwx
namespace: ${NAMESPACE}
spec:
upgradeStrategy: Default
EOF_CAT

cat > ${OPERATOR_DIR}/subscription.yaml <<EOF_CAT
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
labels:
operators.coreos.com/openshift-cert-manager-operator.${NAMESPACE}: ""
name: openshift-cert-manager-operator
namespace: ${NAMESPACE}
spec:
channel: stable
installPlanApproval: Automatic
name: cert-manager
source: community-operators
sourceNamespace: openshift-marketplace
EOF_CAT