Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Test your Kubernetes operator with OLM

Test your Kubernetes operator with OLM

Operator pattern is pioneered by CoreOS, and it is embraced by Kubernetes community. The Operator framework from CoreOS/Red Hat is also getting adoption. Operator Lifecycle Management (OLM) is part of the Operator framework. This talk walks you through testing Kubernetes operator with Operator Lifecycle Management (OLM).

Baiju Muthukadan

May 06, 2019
Tweet

More Decks by Baiju Muthukadan

Other Decks in Programming

Transcript

  1. Test your Kubernetes operator with OLM Baiju Muthukadan Avni Sharma

    May 15, 2019 Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 1 / 19
  2. About Us Baiju is a Senior Software Engineer Baiju Muthukadan,

    Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 2 / 19
  3. About Us Baiju is a Senior Software Engineer Avni is

    an Associate Software Engineer Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 2 / 19
  4. About Us Baiju is a Senior Software Engineer Avni is

    an Associate Software Engineer Both of us works on DevConsole Operator Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 2 / 19
  5. DevConsole Operator Provides a developer-focused view in OpenShift 4 Baiju

    Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 3 / 19
  6. Operator Framework A toolkit to manage Kubernetes native applications, called

    Operators. Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 5 / 19
  7. Operator Lifecycle Manager (OLM) Oversees operator: Installation Updates Lifecycle Baiju

    Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 7 / 19
  8. Catalog Source Repository of Cluster Service Version (CSV) files and

    CRDs Two types gRPC Internal (based on ConfigMap) Public repository: https://www.operatorhub.io To create a custom gRPC use this base image: quay.io/openshift/origin-operator-registry:latest Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 8 / 19
  9. Subscription used to keep CSVs up to date by tracking

    a channel in a package Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 9 / 19
  10. Makefile .PHONY: test-e2e-olm-ci test-e2e-olm-ci: ./vendor $(Q)sed -e "s,REPLACE_IMAGE,registry.svc.ci.openshift.org/ ${OPENSHIFT_BUILD_NAMESPACE}/stable:devconsole-operator-registry," ./test/e2e/catalog_source_OS4.yaml

    | oc apply -f - $(Q)oc apply -f ./test/e2e/subscription_OS4.yaml $(eval DEPLOYED_NAMESPACE := openshift-operators) $(Q)./hack/check-crds.sh $(Q)operator-sdk test local ./test/e2e --no-setup --go-test-flags "-v -timeout=15m" ./vendor: Gopkg.toml Gopkg.lock $(Q)dep ensure ${V_FLAG} -vendor-only Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 10 / 19
  11. CatalogSource # Ref. https://github.com/operator-framework/operator-lifecycle-manager apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name:

    my-catalog namespace: openshift-operator-lifecycle-manager spec: sourceType: grpc image: REPLACE_IMAGE displayName: Community Operators publisher: Red Hat Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 11 / 19
  12. Subscription # Ref. https://github.com/operator-framework/operator-lifecycle-manager apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name:

    my-devconsole namespace: openshift-operators spec: channel: alpha name: devconsole source: my-catalog sourceNamespace: openshift-operator-lifecycle-manager Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 12 / 19
  13. OpenShift CI Configuration base_images: operator-registry: name: "4.0" namespace: ocp tag:

    operator-registry images: - from: operator-registry dockerfile_path: openshift-ci/Dockerfile.registry.intermediate to: operator-registry-base - from: operator-registry-base dockerfile_path: openshift-ci/Dockerfile.registry.build to: devconsole-operator-registry tests: - as: e2e-olm-ci commands: make test-e2e-olm-ci openshift_installer_src: cluster_profile: aws Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 13 / 19
  14. File: openshift-ci/Dockerfile.registry.build FROM quay.io/openshift/origin-operator-registry:latest ARG version=0.1.0 COPY manifests manifests COPY

    deploy/crds/*.yaml manifests/devconsole/${version}/ RUN sed -e "s,REPLACE_IMAGE,registry.svc.ci.openshift.org/ ${OPENSHIFT_BUILD_NAMESPACE}/stable:devconsole-operator," -i manifests/devconsole/${version}/devconsole-operator.v${version} .clusterserviceversion.yaml RUN initializer USER 1001 EXPOSE 50051 CMD ["registry-server", "--termination-log=log.txt"] Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 15 / 19
  15. Directory: manifests/ . └── devconsole ├── 0.1.0 │ └── devconsole-operator.v0.1.0.clusterserviceversion.yaml

    └── devconsole.package.yaml Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 16 / 19
  16. File: manifests/devconsole/devconsole.package.yaml packageName: devconsole channels: - name: alpha currentCSV: devconsole-operator.v0.1.0

    Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 17 / 19
  17. File: manifests/devconsole/0.1.0/devconsole- operator.v0.1.0.clusterserviceversion.yaml apiVersion: operators.coreos.com/v1alpha1 kind: ClusterServiceVersion metadata: annotations: capabilities:

    Full Lifecycle description: The operator that enables a developer-focused perspective categories: "Developer Tools" name: devconsole-operator.v0.1.0 namespace: placeholder spec: apiservicedefinitions: {} customresourcedefinitions: ... Baiju Muthukadan, Avni Sharma Test your Kubernetes operator with OLM May 15, 2019 18 / 19