Skip to content
Example k8s operator built using operator-sdk
Branch: master
Clone or download
Latest commit 8112020 Mar 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build
cmd/manager rename beacause name of repo changed Mar 7, 2019
deploy fixed image name Mar 19, 2019
pkg fixed image name Mar 19, 2019
test/e2e rename beacause name of repo changed Mar 7, 2019
vendor update vendor Mar 7, 2019
version INITIAL COMMIT Mar 6, 2019
.gitignore INITIAL COMMIT Mar 6, 2019
Gopkg.lock update vendor Mar 7, 2019
Gopkg.toml INITIAL COMMIT Mar 6, 2019
README.md rename beacause name of repo changed Mar 7, 2019

README.md

ImmortalContainer Operator

Overview

This is an example operator built using Operator SDK and includes some basic unit and end-to-end tests.

Many ideas and some were taken from the memcached example operator.

Quick Start

This quick start guide walks through the process of building the memcached-operator and running its end-to-end tests.

Prerequisites

  • dep version v0.5.0+.
  • go version v1.10+
  • docker version 17.03+
  • Access to a kubernetes v1.9.0+ cluster

Install the Operator SDK CLI

First, checkout and install the operator-sdk CLI:

$ cd $GOPATH/src/github.com/operator-framework/operator-sdk
$ git checkout master // currently, there are no releases that include the test framework, so use the master for now
$ dep ensure
$ make install github.com/operator-framework/operator-sdk/commands/operator-sdk

Initial Setup

Checkout this repository

$ mkdir $GOPATH/src/github.com/flugel-it
$ cd $GOPATH/src/github.com/flugel-it
$ git clone https://github.com/flugel-it/k8s-go-operator-sdk-operator.git
$ cd k8s-go-operator-sdk-operator

Vendor the dependencies

$ dep ensure

Build the operator

Build the ImmortalContainer operator image and push it to a public registry:

$ export IMAGE=zzmike/immortalcontainer:dev
$ operator-sdk build $IMAGE
$ docker push $IMAGE

Change zzmike to your repository.

Run the tests

To run the tests in test/e2e, first make sure to update the image name in deploy/operator.yaml:

Run the tests that reside in test/e2e:

$ operator-sdk test local ./test/e2e

To run go-test with verbose and limit to 2 parallel tests:

$ operator-sdk test local ./test/e2e --go-test-flags "-v -parallel=2"

To run the tests from an image in the cluster, first build the tests into your image:

$ operator-sdk build $IMAGE --enable-tests
$ docker push $IMAGE

Then, configure the testing environment:

$ export NAMESPACE="my-test"
$ kubectl create -f deploy/crds/immortalcontainer_v1alpha1_immortalcontainer_crd.yaml -n $NAMESPACE
$ kubectl create -f deploy/service_account.yaml -n $NAMESPACE
$ kubectl create -f deploy/role.yaml -n $NAMESPACE
$ kubectl create -f deploy/role_binding.yaml -n $NAMESPACE

Finally, run the tests:

$ operator-sdk test cluster $IMAGE --namespace $NAMESPACE --service-account immortalcontainer-operator
You can’t perform that action at this time.