Skip to content

Commit dd4d64b

Browse files
authored
test(olm): subscription tolerations (#90)
* feat(olm): subscription tolerations and env vars * working version
1 parent 2d24507 commit dd4d64b

File tree

2 files changed

+183
-151
lines changed

2 files changed

+183
-151
lines changed

olm/build-bundles.sh

Lines changed: 166 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -44,182 +44,197 @@ set -x
4444
SCRIPT_NAME=$(basename "$0")
4545

4646
parse_inputs() {
47-
VERSION=""
48-
OPERATOR=""
49-
DEPLOY=false
50-
51-
while [[ "$#" -gt 0 ]]; do
52-
case $1 in
53-
-r | --release)
54-
VERSION="$2"
55-
shift
56-
;;
57-
-c)
58-
OPENSHIFT_ROOT="$2"
59-
shift
60-
;;
61-
-o | --operator)
62-
OPERATOR="$2"
63-
shift
64-
;;
65-
-d | --deploy) DEPLOY=true ;;
66-
*)
67-
echo "Unknown parameter passed: $1"
68-
exit 1
69-
;;
70-
esac
71-
shift
72-
done
47+
VERSION=""
48+
OPERATOR=""
49+
DEPLOY=false
50+
51+
while [[ "$#" -gt 0 ]]; do
52+
case $1 in
53+
-r | --release)
54+
VERSION="$2"
55+
shift
56+
;;
57+
-c)
58+
OPENSHIFT_ROOT="$2"
59+
shift
60+
;;
61+
-o | --operator)
62+
OPERATOR="$2"
63+
shift
64+
;;
65+
-d | --deploy) DEPLOY=true ;;
66+
*)
67+
echo "Unknown parameter passed: $1"
68+
exit 1
69+
;;
70+
esac
71+
shift
72+
done
7373
}
7474

7575
bundle-clean() {
76-
rm -rf "bundle"
77-
rm -rf "bundle.Dockerfile"
76+
rm -rf "bundle"
77+
rm -rf "bundle.Dockerfile"
7878
}
7979

8080
build-bundle() {
81-
opm alpha bundle generate --directory manifests --package "${OPERATOR}-package" --output-dir bundle --channels "stable,$CHANNEL" --default "$CHANNEL"
82-
cp metadata/*.yaml bundle/metadata/
83-
docker build -t "docker.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}" -f bundle.Dockerfile .
84-
docker push "docker.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}"
85-
opm alpha bundle validate --tag "docker.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}" --image-builder docker
81+
opm alpha bundle generate --directory manifests --package "${OPERATOR}-package" --output-dir bundle --channels "stable,$CHANNEL" --default "$CHANNEL"
82+
cp metadata/*.yaml bundle/metadata/
83+
docker build -t "docker.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}" -f bundle.Dockerfile .
84+
docker push "docker.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}"
85+
opm alpha bundle validate --tag "docker.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}" --image-builder docker
8686

87-
echo "Bundle built successfully!"
87+
echo "Bundle built successfully!"
8888
}
8989

9090
catalog-clean() {
91-
if [ -d "catalog" ]; then
92-
rm -rf catalog
93-
fi
94-
95-
rm -f catalog.Dockerfile
96-
rm -f catalog-source.yaml
97-
rm -f subscription.yaml
98-
rm -f operator-group.yaml
91+
if [ -d "catalog" ]; then
92+
rm -rf catalog
93+
fi
94+
95+
rm -f catalog.Dockerfile
96+
rm -f catalog-source.yaml
97+
rm -f subscription.yaml
98+
rm -f operator-group.yaml
9999
}
100100

101101
catalog() {
102-
mkdir -p catalog
103-
104-
opm generate dockerfile catalog
105-
106-
echo "Initiating package: ${OPERATOR}"
107-
opm init "stackable-${OPERATOR}-operator" \
108-
--default-channel="$CHANNEL" \
109-
--output yaml >"catalog/stackable-${OPERATOR}-operator.yaml"
110-
##--description="TODO: add description here" \
111-
112-
echo "Add operator to package: ${OPERATOR}"
113-
{
114-
echo "---"
115-
echo "schema: olm.channel"
116-
echo "package: stackable-${OPERATOR}-operator"
117-
echo "name: \"$CHANNEL\""
118-
echo "entries:"
119-
echo "- name: ${OPERATOR}-operator.v${VERSION}"
120-
echo "---"
121-
echo "schema: olm.channel"
122-
echo "package: stackable-${OPERATOR}-operator"
123-
echo "name: stable"
124-
echo "entries:"
125-
echo "- name: ${OPERATOR}-operator.v${VERSION}"
126-
127-
} >>"catalog/stackable-${OPERATOR}-operator.yaml"
128-
echo "Render operator: ${OPERATOR}"
129-
opm render "docker.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}" --output=yaml >>"catalog/stackable-${OPERATOR}-operator.yaml"
130-
131-
echo "Validating catalog..."
132-
opm validate catalog
133-
134-
echo "Build and push catalog for all ${OPERATOR} operator..."
135-
docker build . -f catalog.Dockerfile -t "docker.stackable.tech/sandbox/stackable-${OPERATOR}-catalog:${VERSION}"
136-
docker push "docker.stackable.tech/sandbox/stackable-${OPERATOR}-catalog:${VERSION}"
137-
138-
echo "Generating catalog source..."
139-
{
140-
echo "---"
141-
echo "apiVersion: operators.coreos.com/v1alpha1"
142-
echo "kind: CatalogSource"
143-
echo "metadata:"
144-
echo " name: stackable-${OPERATOR}-catalog"
145-
echo "spec:"
146-
echo " sourceType: grpc"
147-
echo " image: docker.stackable.tech/sandbox/stackable-${OPERATOR}-catalog:${VERSION}"
148-
echo " displayName: Stackable Catalog"
149-
echo " publisher: Stackable GmbH"
150-
echo " updateStrategy:"
151-
echo " registryPoll:"
152-
echo " interval: 10m"
153-
} >catalog-source.yaml
154-
155-
echo "Generating subscription ..."
156-
{
157-
echo "---"
158-
echo "apiVersion: operators.coreos.com/v1alpha1"
159-
echo "kind: Subscription"
160-
echo "metadata:"
161-
echo " name: stackable-${OPERATOR}-subscription"
162-
echo "spec:"
163-
echo " channel: '$CHANNEL'"
164-
echo " name: stackable-${OPERATOR}-operator" # this is the package name NOT the operator-name
165-
echo " source: stackable-${OPERATOR}-catalog"
166-
echo " sourceNamespace: stackable-operators"
167-
echo " startingCSV: ${OPERATOR}-operator.v${VERSION}"
168-
} >subscription.yaml
169-
170-
echo "Generating operator group ..."
171-
{
172-
echo "---"
173-
echo "apiVersion: operators.coreos.com/v1"
174-
echo "kind: OperatorGroup"
175-
echo "metadata:"
176-
echo " name: stackable-operator-group"
177-
echo "spec:"
178-
echo " targetNamespaces:"
179-
echo " - stackable-operators"
180-
} >operator-group.yaml
181-
182-
echo "Catalog, operator group and subscription built (but not deployed) successfully!"
102+
mkdir -p catalog
103+
104+
opm generate dockerfile catalog
105+
106+
echo "Initiating package: ${OPERATOR}"
107+
opm init "stackable-${OPERATOR}-operator" \
108+
--default-channel="$CHANNEL" \
109+
--output yaml >"catalog/stackable-${OPERATOR}-operator.yaml"
110+
##--description="TODO: add description here" \
111+
112+
echo "Add operator to package: ${OPERATOR}"
113+
{
114+
echo "---"
115+
echo "schema: olm.channel"
116+
echo "package: stackable-${OPERATOR}-operator"
117+
echo "name: \"$CHANNEL\""
118+
echo "entries:"
119+
echo "- name: ${OPERATOR}-operator.v${VERSION}"
120+
echo "---"
121+
echo "schema: olm.channel"
122+
echo "package: stackable-${OPERATOR}-operator"
123+
echo "name: stable"
124+
echo "entries:"
125+
echo "- name: ${OPERATOR}-operator.v${VERSION}"
126+
127+
} >>"catalog/stackable-${OPERATOR}-operator.yaml"
128+
echo "Render operator: ${OPERATOR}"
129+
opm render "docker.stackable.tech/sandbox/${OPERATOR}-bundle:${VERSION}" --output=yaml >>"catalog/stackable-${OPERATOR}-operator.yaml"
130+
131+
echo "Validating catalog..."
132+
opm validate catalog
133+
134+
echo "Build and push catalog for all ${OPERATOR} operator..."
135+
docker build . -f catalog.Dockerfile -t "docker.stackable.tech/sandbox/stackable-${OPERATOR}-catalog:${VERSION}"
136+
docker push "docker.stackable.tech/sandbox/stackable-${OPERATOR}-catalog:${VERSION}"
137+
138+
echo "Generating catalog source..."
139+
cat >catalog-source.yaml <<CATALOGSOURCE
140+
---
141+
apiVersion: operators.coreos.com/v1alpha1
142+
kind: CatalogSource
143+
metadata:
144+
name: stackable-${OPERATOR}-catalog
145+
spec:
146+
sourceType: grpc
147+
image: docker.stackable.tech/sandbox/stackable-${OPERATOR}-catalog:${VERSION}
148+
displayName: Stackable Catalog
149+
publisher: Stackable GmbH
150+
updateStrategy:
151+
registryPoll:
152+
interval: 10m
153+
grpcPodConfig:
154+
tolerations:
155+
- key: keep-out
156+
value: "yes"
157+
operator: Equal
158+
effect: NoSchedule
159+
CATALOGSOURCE
160+
161+
echo "Generating subscription ..."
162+
cat >subscription.yaml <<SUBSCRIPTION
163+
---
164+
apiVersion: operators.coreos.com/v1alpha1
165+
kind: Subscription
166+
metadata:
167+
name: stackable-${OPERATOR}-subscription
168+
spec:
169+
channel: '$CHANNEL'
170+
name: stackable-${OPERATOR}-operator # this is the package name NOT the operator-name
171+
source: stackable-${OPERATOR}-catalog
172+
sourceNamespace: stackable-operators
173+
startingCSV: ${OPERATOR}-operator.v${VERSION}
174+
config:
175+
tolerations:
176+
- key: keep-out
177+
value: "yes"
178+
operator: Equal
179+
effect: NoSchedule
180+
env:
181+
- name: SOME_IMPORTANT_FEATURE_FLAG
182+
value: "turn-it-on"
183+
SUBSCRIPTION
184+
185+
echo "Generating operator group ..."
186+
cat >operator-group.yaml <<OPERATORGROUP
187+
---
188+
apiVersion: operators.coreos.com/v1
189+
kind: OperatorGroup
190+
metadata:
191+
name: stackable-operator-group
192+
spec:
193+
targetNamespaces:
194+
- stackable-operators
195+
OPERATORGROUP
196+
197+
echo "Catalog, operator group and subscription built (but not deployed) successfully!"
183198
}
184199

185200
deploy() {
186-
if $DEPLOY; then
187-
kubectl describe namespace stackable-operators || kubectl create namespace stackable-operators
188-
kubectl apply --namespace stackable-operators \
189-
-f catalog-source.yaml \
190-
-f subscription.yaml \
191-
-f operator-group.yaml
192-
echo "Operator deployment done!"
193-
else
194-
echo "Skip operator deployment!"
195-
fi
201+
if $DEPLOY; then
202+
kubectl describe namespace stackable-operators || kubectl create namespace stackable-operators
203+
kubectl apply --namespace stackable-operators \
204+
-f catalog-source.yaml \
205+
-f subscription.yaml \
206+
-f operator-group.yaml
207+
echo "Operator deployment done!"
208+
else
209+
echo "Skip operator deployment!"
210+
fi
196211
}
197212

198213
main() {
199-
parse_inputs "$@"
200-
if [ -z "${VERSION}" ] || [ -z "${OPENSHIFT_ROOT}" ] || [ -z "${OPERATOR}" ]; then
201-
echo "Usage: $SCRIPT_NAME -r <release> -o <operator> -c <path-to-openshift-repo>"
202-
exit 1
203-
fi
214+
parse_inputs "$@"
215+
if [ -z "${VERSION}" ] || [ -z "${OPENSHIFT_ROOT}" ] || [ -z "${OPERATOR}" ]; then
216+
echo "Usage: $SCRIPT_NAME -r <release> -o <operator> -c <path-to-openshift-repo>"
217+
exit 1
218+
fi
204219

205-
CHANNEL="$(echo "$VERSION"|sed 's/\.[^.]*$//')"
220+
CHANNEL="$(echo "$VERSION" | sed 's/\.[^.]*$//')"
206221

207-
if [ "$OPERATOR" == "spark-k8s" ]; then
208-
echo "Renaming operator from spark-k8s to spark"
209-
OPERATOR="spark"
210-
fi
222+
if [ "$OPERATOR" == "spark-k8s" ]; then
223+
echo "Renaming operator from spark-k8s to spark"
224+
OPERATOR="spark"
225+
fi
211226

212-
# this is the same folder that is also used by build-manifests.sh
213-
cd "${OPENSHIFT_ROOT}/operators/stackable-${OPERATOR}-operator/${VERSION}"
227+
# this is the same folder that is also used by build-manifests.sh
228+
cd "${OPENSHIFT_ROOT}/operators/stackable-${OPERATOR}-operator/${VERSION}"
214229

215-
# clean up any residual files from previous actions
216-
bundle-clean
217-
build-bundle
230+
# clean up any residual files from previous actions
231+
bundle-clean
232+
build-bundle
218233

219-
catalog-clean
220-
catalog
234+
catalog-clean
235+
catalog
221236

222-
deploy
237+
deploy
223238
}
224239

225240
main "$@"

olm/replicated/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# OKD on replicated
2+
3+
## Troubleshooting guide
4+
5+
### OLM
6+
7+
#### "community-operators" Pods are crashing due to "cache requires rebuild" error
8+
9+
Disable the community-operator catalog source which is enabled by default.
10+
This is a source of problems such as [this](https://access.redhat.com/solutions/7049642)
11+
and it prevents the Stackable ops from installation.
12+
13+
To disable the community-operators catalog source run:
14+
15+
```bash
16+
kubectl patch operatorhubs/cluster --type merge --patch '{"spec":{"sources":[{"disabled": true,"name": "community-operators"}]}}'
17+
```

0 commit comments

Comments
 (0)