Skip to content

Commit 2d39f3f

Browse files
authored
Create stable channel and 1.0.0 release (#44)
* Create stable channel and 1.0.0 release Create a new channel called stable which will host the 1.0.0 release of Smart Gateway Operator. * Set Smart Gateway container image from env var Setting the container image for the Smart Gateway from an environment variable allows for setting a specific version of the Smart Gateway to come up, allowing versions to be tied to the Operator container image itself, and thus a CSV version. Looking at other Operators, any dependent images seem to get set via environment variable on the Operator, and then used for instantiating the desired set of images for that CSV. If the SMARTGATEWAY_IMAGE environment variable is not set, then the default is to use the latest image from quay.io/infrawatch/smart-gateway. * Don't reference beta1 in semver * Only release on tagged versions
1 parent 3f80771 commit 2d39f3f

24 files changed

+677
-98
lines changed

.osdk-scorecard.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
scorecard:
2-
# Setting a global scorecard option
2+
version: v1alpha2
33
output: text
4+
bundle: deploy/olm-catalog/smart-gateway-operator/1.0.0/metadata
45
plugins:
56
- basic:
67
cr-manifest:
78
- "deploy/crds/smartgateway.infra.watch_v2alpha1_smartgateway.metrics_cr.yaml"
9+
csv-path: "deploy/olm-catalog/smart-gateway-operator/1.0.0/smart-gateway-operator.v1.0.0.clusterserviceversion.yaml"
810
- olm:
911
cr-manifest:
1012
- "deploy/crds/smartgateway.infra.watch_v2alpha1_smartgateway.metrics_cr.yaml"
11-
csv-path: "deploy/olm-catalog/smart-gateway-operator/0.2.0/smart-gateway-operator.v0.2.0.clusterserviceversion.yaml"
13+
csv-path: "deploy/olm-catalog/smart-gateway-operator/1.0.0/smart-gateway-operator.v1.0.0.clusterserviceversion.yaml"

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@ script:
1313
- operator-courier verify --ui_validate_io deploy/olm-catalog/smart-gateway-operator
1414
- ansible-lint roles/smartgateway/
1515
after_success:
16-
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH;
17-
else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
18-
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH"
19-
- "./build/travis/after_success.sh"
16+
- if [ "$TRAVIS_TAG" == "" ]; then echo "Not a tagged release, skipping after_success.sh"; else ./build/travis/after_success.sh; fi

README.md

Lines changed: 147 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,45 +26,174 @@ development is available at https://github.com/code-ready/crc.
2626
A procedure for testing in CodeReady Containers will be available soon.
2727

2828
* buildah
29-
* 1.12.0
29+
* 1.14.0
3030
* kubernetes
31-
* v1.14.0
31+
* v1.16.2
3232
* crc
33-
* crc version: 1.3.0+918756b
33+
* crc version: 1.6.0+8ef676f
3434
* oc
3535
* openshift-clients-4.2.0-201910041700
3636
* operator-sdk
37-
* v0.12.0 (!0.13.0 which causes regressions via `gen-csv` command)
37+
* v0.15.2 (!0.13.0 which causes regressions via `gen-csv` command)
3838

39-
### Set up crc and buildah
39+
### Set up CRC and buildah
4040

41-
<todo>
41+
Setup CRC and then login with the `kubeadmin` user.
42+
43+
```
44+
$ crc setup
45+
$ crc start --memory=32768
46+
$ crc console --credentials
47+
```
48+
49+
Install `buildah` via `dnf`.
50+
51+
```
52+
sudo dnf install buildah -y
53+
```
54+
55+
### Login to CRC registry
56+
57+
```
58+
REGISTRY=$(oc registry info)
59+
TOKEN=$(oc whoami -t)
60+
INTERNAL_REGISTRY=$(oc registry info --internal=true)
61+
buildah login --tls-verify=false -u openshift -p "${TOKEN}" "${REGISTRY}"
62+
```
4263

4364
### Build the operator
4465

45-
<todo>
66+
```
67+
buildah bud -f build/Dockerfile -t "${REGISTRY}/default/smart-gateway-operator:latest" .
68+
buildah push --tls-verify=false "${REGISTRY}/default/smart-gateway-operator:latest"
69+
```
4670

4771
### Deploy with the newly built operator
4872

49-
<todo>
73+
Install required RBAC rules and service account.
5074

51-
### FIXME - Unit testing
75+
```
76+
oc apply \
77+
-f deploy/role_binding.yaml \
78+
-f deploy/role.yaml \
79+
-f deploy/service_account.yaml \
80+
-f deploy/operator_group.yaml
81+
```
5282

53-
With molecule (Currently broken)
83+
Pick a version from `deploy/olm-catalog/smart-gateway-operator/` and run the
84+
following commands. Adjust version to what you want to test. We'll be using
85+
`v1.0.0` as our example version.
5486

55-
### Integration testing
87+
```
88+
CSV_VERSION=1.0.0
89+
INTERNAL_REGISTRY=$(oc registry info --internal=true)
90+
oc apply -f deploy/olm-catalog/smart-gateway-operator/${CSV_VERSION}/smartgateway.infra.watch_smartgateways_crd.yaml
91+
92+
oc create -f <(sed "\
93+
s|image: .\+/smart-gateway-operator:.\+$|image: ${INTERNAL_REGISTRY}/default/smart-gateway-operator:latest|g;
94+
s|namespace: placeholder|namespace: default|g"\
95+
"deploy/olm-catalog/smart-gateway-operator/${CSV_VERSION}/smart-gateway-operator.v${CSV_VERSION}.clusterserviceversion.yaml")
96+
```
5697

57-
Test the newly built operator with the Service Telemetry Framework (STF).
98+
Validate that installation of the `ClusterServiceVersion` is progressing via
99+
the `oc` CLI console.
100+
```
101+
oc get csv --watch
102+
```
103+
If you see `PHASE: Succeeded` then your CSV has been properly imported and
104+
your Operator should be running locally. You can validate this by running `oc
105+
get pods` and looking for the `smart-gateway-operator` and that it is
106+
`Running`.
58107

59-
<todo>
108+
You can bring up the logs of the Smart Gateway Operator by running `oc logs
109+
<<pod_name>> -c operator`.
60110

61111
## Creating a Smart Gateway
62112

63-
<update>
113+
To create a Smart Gateway, you'll need to connect it to a compatible AMQP 1.x
114+
message bus. For demonstration purposes we're going to use the Red Hat AMQ
115+
Interconnect Operator, create an AMQ Interconnect instance, then create a Smart
116+
Gateway instance that connects to it.
117+
118+
### Create AMQ Interconnect Subscription
119+
120+
```
121+
oc apply -f - <<EOF
122+
apiVersion: operators.coreos.com/v1alpha1
123+
kind: Subscription
124+
metadata:
125+
name: amq7-interconnect-operator
126+
namespace: default
127+
spec:
128+
channel: 1.2.0
129+
installPlanApproval: Automatic
130+
name: amq7-interconnect-operator
131+
source: redhat-operators
132+
sourceNamespace: openshift-marketplace
133+
EOF
134+
```
64135

65-
Start a new smart gateway by creating a CustomResource object
66-
based on the example:
136+
You can check the status of the AMQ Interconnect ClusterServiceVersion
137+
installation with `oc get csv`. When complete you should see `PHASE:
138+
Succeeded`.
67139

68-
```shell
69-
oc create -f deploy/crds/smartgateway.infra.watch_v2alpha1_smartgateway.metrics_cr.yaml
140+
### Create AMQ Interconnect Instance
141+
142+
```
143+
oc apply -f - <<EOF
144+
apiVersion: interconnectedcloud.github.io/v1alpha1
145+
kind: Interconnect
146+
metadata:
147+
name: amq-interconnect
148+
namespace: default
149+
spec:
150+
addresses:
151+
- distribution: closest
152+
prefix: closest
153+
- distribution: multicast
154+
prefix: multicast
155+
- distribution: closest
156+
prefix: unicast
157+
- distribution: closest
158+
prefix: exclusive
159+
- distribution: multicast
160+
prefix: broadcast
161+
deploymentPlan:
162+
livenessPort: 8888
163+
placement: Any
164+
resources: {}
165+
role: interior
166+
size: 2
167+
edgeListeners:
168+
- port: 45672
169+
interRouterListeners:
170+
- port: 55672
171+
listeners:
172+
- port: 5672
173+
- authenticatePeer: true
174+
expose: true
175+
http: true
176+
port: 8080
177+
users: amq-interconnect-users
178+
EOF
179+
```
180+
181+
Validate that you see both AMQ Interconnect routers come up with `oc get pods`.
182+
183+
### Create Smart Gateway Instance
184+
185+
```
186+
oc apply -f - <<EOF
187+
apiVersion: smartgateway.infra.watch/v2alpha1
188+
kind: SmartGateway
189+
metadata:
190+
name: cloud1-metrics
191+
namespace: default
192+
spec:
193+
amqpUrl: amq-interconnect:5672/collectd/telemetry
194+
debug: true
195+
prefetch: 15000
196+
serviceType: metrics
197+
size: 1
198+
EOF
70199
```

build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM quay.io/operator-framework/ansible-operator:v0.12.0
1+
FROM quay.io/operator-framework/ansible-operator:v0.14.1
22

33
COPY roles/ ${HOME}/roles/
44
COPY watches.yaml ${HOME}/watches.yaml

build/metadata.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
CSV_VERSION=${CSV_VERSION:-1.0.0}
3+
UNIXDATE=$(date +%s)
4+
ORGANIZATION=${ORGANIZATION:-infrawatch}

build/new_csv_version.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env sh
2+
3+
if [ -z "$CSV_VERSION" ]; then
4+
echo -n "CSV version to create [e.g. 1.1.0]: "
5+
read CSV_VERSION
6+
fi
7+
8+
if [ -z "$FROM_VERSION" ]; then
9+
echo -n "CSV version to upgrade from [e.g. 1.0.0]: "
10+
read FROM_VERSION
11+
fi
12+
13+
if [ -z "$CSV_CHANNEL" ]; then
14+
echo -n "CSV channel to publish to [e.g. stable]: "
15+
read CSV_CHANNEL
16+
fi
17+
18+
19+
operator-sdk generate csv --csv-version=${CSV_VERSION} \
20+
--from-version=${FROM_VERSION} \
21+
--operator-name smart-gateway-operator \
22+
--update-crds \
23+
--csv-channel="${CSV_CHANNEL}"

build/push_app2quay.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
# contents of this file originally from https://redhat-connect.gitbook.io/certified-operator-guide/ocp-deployment/openshift-deployment
33

44
set -e
5-
6-
CSV_VERSION=${CSV_VERSION:-0.2.0}
7-
UNIXDATE=$(date +%s)
8-
ORGANIZATION=${ORGANIZATION:-infrawatch}
5+
REL=$(dirname "$0"); source "${REL}/metadata.sh"
96

107
if [ -z "$USERNAME" ]; then
118
echo -n "Username: "

build/travis/after_success.sh

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@
22

33
# Fail on error
44
set -e
5-
65
REL=$(dirname "$0")
76

8-
# Add everything, get ready for commit. But only do it if we're on master or a
9-
# named branch of the format <#>.<#>.X. If you want to deploy on different
10-
# branches, you can change this.
11-
if [[ "$BRANCH" =~ ^master$|^[0-9]+\.[0-9]+\.X$ ]]; then
12-
echo "Branch is master, so push new application to Quay registry"
13-
export PATH=$HOME/bin:$PATH
14-
curl -L https://github.com/operator-framework/operator-sdk/releases/download/v0.15.2/operator-sdk-v0.15.2-x86_64-linux-gnu -o $HOME/bin/operator-sdk
15-
chmod +x $HOME/bin/operator-sdk
16-
${REL}/../update_csv.sh
17-
${REL}/../push_app2quay.sh
18-
else
19-
echo "Not on master, so won't push new application artifacts"
20-
fi
7+
echo "Pushing new application to Quay registry"
8+
export PATH=$HOME/bin:$PATH
9+
curl -L https://github.com/operator-framework/operator-sdk/releases/download/v0.15.2/operator-sdk-v0.15.2-x86_64-linux-gnu -o "$HOME/bin/operator-sdk"
10+
chmod +x "$HOME/bin/operator-sdk"
11+
12+
# Push new application version, but strip the first character which is expected to be 'v'
13+
# Why not just create tags that don't have 'v'? Because the container image versions are expected to lead with a 'v'. Fun!
14+
CSV_VERSION="${TRAVIS_TAG:1}" "${REL}/../push_app2quay.sh""

build/update_csv.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
#!/usr/bin/env sh
2-
operator-sdk generate csv --csv-version 0.2.0 --operator-name smart-gateway-operator --update-crds
2+
set -e
3+
REL=$(dirname "$0"); source "${REL}/metadata.sh"
4+
operator-sdk generate csv --csv-version=${CSV_VERSION} --operator-name smart-gateway-operator --update-crds

deploy/crds/smartgateway.infra.watch_smartgateways_crd.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ spec:
8989
type: integer
9090
containerImagePath:
9191
description: Path to the container image this Operator will deploy. Value is defined as the standard registry/image_name:tag
92-
format. Defaults to 'quay.io/infrawatch/smart-gateway:latest'
92+
format.
9393
type: string
9494
useTimestamp:
9595
description: Use the source timestamp (time when data was collected) rather than let Prometheus write when the data was

deploy/olm-catalog/smart-gateway-operator/0.2.0/smart-gateway-operator.v0.2.0.clusterserviceversion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ spec:
281281
name: smart-gateway-operator
282282
links:
283283
- name: Source Code
284-
url: https://github.com/infrawatch/smart-gateway-operator.0.2.0
284+
url: https://github.com/infrawatch/smart-gateway-operator
285285
maintainers:
286286
287287
name: Red Hat CloudOps DFG
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
FROM scratch
22

3-
LABEL operators.operatorframework.io.bundle.mediatype.v1=plain
3+
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
44
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
55
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
66
LABEL operators.operatorframework.io.bundle.package.v1=smart-gateway-operator
7-
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
8-
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha
7+
LABEL operators.operatorframework.io.bundle.channels.v1=stable
8+
LABEL operators.operatorframework.io.bundle.channel.default.v1=stable
99

1010
COPY /*.yaml /manifests/
1111
COPY /metadata/annotations.yaml /metadata/annotations.yaml
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
annotations:
2-
operators.operatorframework.io.bundle.channel.default.v1: alpha
3-
operators.operatorframework.io.bundle.channels.v1: alpha
2+
operators.operatorframework.io.bundle.channel.default.v1: stable
3+
operators.operatorframework.io.bundle.channels.v1: stable
44
operators.operatorframework.io.bundle.manifests.v1: manifests/
5-
operators.operatorframework.io.bundle.mediatype.v1: plain
5+
operators.operatorframework.io.bundle.mediatype.v1: registry+v1
66
operators.operatorframework.io.bundle.metadata.v1: metadata/
77
operators.operatorframework.io.bundle.package.v1: smart-gateway-operator

0 commit comments

Comments
 (0)