Skip to content

Instantly share code, notes, and snippets.

@ruo91
Created March 22, 2021 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruo91/9f4f27db6b761844d5a081d1e44b3f24 to your computer and use it in GitHub Desktop.
Save ruo91/9f4f27db6b761844d5a081d1e44b3f24 to your computer and use it in GitHub Desktop.
OpenShift v4.6 - Service Telemetry Framework 1.2 (Test)

OpenShift v4.6 - Service Telemetry Framework 1.2

https://infrawatch.github.io/documentation/

1. STF Operator Index 다운로드

- RedHat Operator

[root@bastion ~]# podman pull registry.redhat.io/redhat/redhat-operator-index:v4.6

- STF Catalog

[root@bastion ~]# podman pull quay.io/redhat-operators-stf/stf-catalog:v4.6

- Infrawatch

[root@bastion ~]# podman pull quay.io/infrawatch-operators/infrawatch-catalog:latest

- OperatorHub IO

[root@bastion ~]# podman pull quay.io/operatorhubio/catalog:latest

2. index.db 패키지 초기화

[root@bastion ~]# opm index prune \
-f quay.io/redhat-operators-stf/stf-catalog:v4.6 \
-t registry.ybkim.ocp4.local/olm/stf-operator-index:latest \
-p amq7-cert-manager-operator

[root@bastion ~]# opm index prune \
-f quay.io/infrawatch-operators/infrawatch-catalog:latest \
-t registry.ybkim.ocp4.local/olm/infrawatch-operator-index:latest \
-p service-telemetry-operator,smart-gateway-operator

[root@bastion ~]# opm index prune \
-f quay.io/operatorhubio/catalog:latest \
-t registry.ybkim.ocp4.local/olm/operatorhubio-catalog-operator-index:latest \
-p elastic-cloud-eck,grafana-operator,prometheus,prometheus-exporter-operator

3. custom operator index 이미지 업로드

[root@bastion ~]# for i in {stf-operator,infrawatch-operator,operatorhubio-catalog-operator}; do podman push --tls-verify=false registry.ybkim.ocp4.local/olm/$i-index:latest; done

4. 이미지 미러링

[root@bastion ~]# oc adm catalog mirror \
registry.ybkim.ocp4.local/olm/stf-operator-index:latest \
registry.ybkim.ocp4.local --insecure --filter-by-os='.*'

[root@bastion ~]# oc adm catalog mirror \
registry.ybkim.ocp4.local/olm/infrawatch-operator-index:latest \
registry.ybkim.ocp4.local --insecure --filter-by-os='.*'

[root@bastion ~]# oc adm catalog mirror \
registry.ybkim.ocp4.local/olm/operatorhubio-catalog-operator-index:latest \
registry.ybkim.ocp4.local --insecure --filter-by-os='.*'

5. Container 구동

[root@bastion ~]# podman run -d --name "stf-operator" -p 50051:50051 registry.ybkim.ocp4.local/olm/stf-operator-index:latest
[root@bastion ~]# podman run -d --name "infrawatch-operator" -p 50052:50051 registry.ybkim.ocp4.local/olm/infrawatch-operator-index:latest
[root@bastion ~]# podman run -d --name "operatorhubio-catalog-operator" -p 50053:50051 registry.ybkim.ocp4.local/olm/operatorhubio-catalog-operator-index:latest

6. 디비 복사

[root@bastion ~]# podman cp stf-operator:/database/index.db stf-operator.db
[root@bastion ~]# podman cp infrawatch-operator:/database/index.db infrawatch-operator.db
[root@bastion ~]# podman cp operatorhubio-catalog-operator:/database/index.db operatorhubio-catalog-operator.db

7. bundle 이미지 생성

[root@bastion ~]# for i in {stf-operator,infrawatch-operator,operatorhubio-catalog-operator}; do podman build -t registry.ybkim.ocp4.local/olm/$i-bundle:latest -f $i-bundle.dockerfile; done
[root@bastion ~]# for i in {stf-operator,infrawatch-operator,operatorhubio-catalog-operator}; do podman push --tls-verify=false registry.ybkim.ocp4.local/olm/$i-bundle:latest; done

8. index.db 초기화

[root@bastion ~]# opm index prune \
-f registry.ybkim.ocp4.local/olm/stf-operator-bundle:latest \
-t registry.ybkim.ocp4.local/olm/stf-operator-index:v1 \
-p amq7-cert-manager-operator

[root@bastion ~]# opm index prune \
-f registry.ybkim.ocp4.local/olm/infrawatch-operator-bundle:latest \
-t registry.ybkim.ocp4.local/olm/infrawatch-operator-index:v1 \
-p service-telemetry-operator,smart-gateway-operator

[root@bastion ~]# opm index prune \
-f registry.ybkim.ocp4.local/olm/operatorhubio-catalog-operator-bundle:latest \
-t registry.ybkim.ocp4.local/olm/operatorhubio-catalog-operator-index:v1 \
-p elastic-cloud-eck,grafana-operator,prometheus,prometheus-exporter-operator

[root@bastion ~]# for i in {stf-operator,infrawatch-operator,operatorhubio-catalog-operator}; do podman push --tls-verify=false registry.ybkim.ocp4.local/olm/$i-index:v1; done

9. Catalog 소스 생성

[root@bastion ~]# cat << EOF > catalog-source.yaml
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: redhat-operators-stf
  namespace: openshift-marketplace
spec:
  displayName: Red Hat STF Operators
  image: registry.ybkim.ocp4.local/olm/stf-operator-index:v1
  publisher: Red Hat
  sourceType: grpc
  updateStrategy:
    registryPoll:
      interval: 30m
---
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: infrawatch-operators
  namespace: openshift-marketplace
spec:
  displayName: InfraWatch Operators
  image: registry.ybkim.ocp4.local/olm/infrawatch-operator-index:v1
  publisher: InfraWatch
  sourceType: grpc
  updateStrategy:
    registryPoll:
      interval: 30m
---
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: operatorhubio-operators
  namespace: openshift-marketplace
spec:
  sourceType: grpc
  image: registry.ybkim.ocp4.local/olm/operatorhubio-catalog-operator-index:v1
  displayName: OperatorHub.io Operators
  publisher: OperatorHub.io
EOF
[root@bastion ~]# oc create -f catalog-source.yaml

10. ImageContentSourcePolicy

[root@bastion ~]# cat << EOF > imageContentSourcePolicy.yaml
apiVersion: operator.openshift.io/v1alpha1
kind: ImageContentSourcePolicy
metadata:
  name: redhat-operators-stf
spec:
  repositoryDigestMirrors:
  - mirrors:
    - registry.ybkim.ocp4.local/amq7/amq-cert-manager
    source: registry.redhat.io/amq7/amq-cert-manager
  - mirrors:
    - registry.ybkim.ocp4.local/redhat-operators-stf/amq7-cert-manager-operator-bundle
    source: quay.io/redhat-operators-stf/amq7-cert-manager-operator-bundle
---
apiVersion: operator.openshift.io/v1alpha1
kind: ImageContentSourcePolicy
metadata:
  name: infrawatch-operators
spec:
  repositoryDigestMirrors:
  - mirrors:
    - registry.ybkim.ocp4.local/infrawatch-operators/service-telemetry-operator-bundle
    source: quay.io/infrawatch-operators/service-telemetry-operator-bundle
  - mirrors:
    - registry.ybkim.ocp4.local/infrawatch/service-telemetry-operator
    source: quay.io/infrawatch/service-telemetry-operator
  - mirrors:
    - registry.ybkim.ocp4.local/infrawatch-operators/smart-gateway-operator-bundle
    source: quay.io/infrawatch-operators/smart-gateway-operator-bundle
  - mirrors:
    - registry.ybkim.ocp4.local/infrawatch/smart-gateway-operator
    source: quay.io/infrawatch/smart-gateway-operator
---
apiVersion: operator.openshift.io/v1alpha1
kind: ImageContentSourcePolicy
metadata:
  name: operatorhubio-operators
spec:
  repositoryDigestMirrors:
  - mirrors:
    - registry.ybkim.ocp4.local/eck/eck-operator
    source: docker.elastic.co/eck/eck-operator
  - mirrors:
    - registry.ybkim.ocp4.local/operatorhubio/prometheus
    source: quay.io/operatorhubio/prometheus
  - mirrors:
    - registry.ybkim.ocp4.local/3scale/prometheus-exporter-operator
    source: quay.io/3scale/prometheus-exporter-operator
  - mirrors:
    - registry.ybkim.ocp4.local/coreos/prometheus-operator
    source: quay.io/coreos/prometheus-operator
  - mirrors:
    - registry.ybkim.ocp4.local/integreatly/grafana-operator
    source: quay.io/integreatly/grafana-operator
  - mirrors:
    - registry.ybkim.ocp4.local/operatorhubio/elastic-cloud-eck
    source: quay.io/operatorhubio/elastic-cloud-eck
  - mirrors:
    - registry.ybkim.ocp4.local/operatorhubio/grafana-operator
    source: quay.io/operatorhubio/grafana-operator
  - mirrors:
    - registry.ybkim.ocp4.local/operatorhubio/prometheus
    source: quay.io/operatorhubio/prometheus
  - mirrors:
    - registry.ybkim.ocp4.local/operatorhubio/prometheus-exporter-operator
    source: quay.io/operatorhubio/prometheus-exporter-operator
EOF
[root@bastion ~]# oc create -f imageContentSourcePolicy.yaml

11. Operator Subscription 생성

[root@bastion ~]# cat << EOF > subscription.yaml
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: amq7-cert-manager-operator
  namespace: openshift-operators
spec:
  channel: alpha
  installPlanApproval: Automatic
  name: amq7-cert-manager-operator
  source: redhat-operators-stf
  sourceNamespace: openshift-marketplace
  targetNamespaces: global
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: elastic-cloud-eck
  namespace: service-telemetry
spec:
  channel: stable
  installPlanApproval: Automatic
  name: elastic-cloud-eck
  source: operatorhubio-operators
  sourceNamespace: openshift-marketplace
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: service-telemetry-operator
  namespace: service-telemetry
spec:
  channel: stable-1.2
  installPlanApproval: Automatic
  name: service-telemetry-operator
  source: infrawatch-operators
  sourceNamespace: openshift-marketplace
EOF
[root@bastion ~]# oc create -f subscription.yaml

99. 이슈 이미지 빌드

[root@bastion ~]# podman build -t registry.ybkim.ocp4.local/redhat-operators-stf/amq7-cert-manager-operator-bundle:v1.0.0 -f amq7-cert-manager-operator-bundle.dockerfile
[root@bastion ~]# podman push --tls-verify=false registry.ybkim.ocp4.local/redhat-operators-stf/amq7-cert-manager-operator-bundle:v1.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment