Skip to content
SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.
Go Shell Other
Branch: master
Clone or download
djzager and fabianvf refactor(ansible): store relevant data on watch (#2067)
* refactor(ansible): store relevant data on watch

Bring all of the logic for how values are reconciled, and where
important values are stored, into the watches package. This allows us to
handle command line flags, environment variables, defaults, and values
from the watches file in one place with sane defaults.

- Add new functions to watches package `New()` and `Validate()`
- Move `getMaxWorkers()` to watches package (from runner)
- Handle command line arguments in watches package

* Don't pass flags to watches.Load()

Instead of giving all of the flags to `watches.Load()`, we should only
pass down the values that are needed.

Also update `New()` so that it's possible to create a valid watch.

* Log invalid value for maxWorkers and use default
Latest commit 2b8846c Oct 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github .github: Update bug report issue template (#1300) Apr 9, 2019
ci reorganize deletions so the operator can remove the finalizer (#2074) Oct 17, 2019
cmd/operator-sdk cmd: fix typo (#2064) Oct 15, 2019
doc Documents Unsupported ansible modules Q/A (#2068) Oct 17, 2019
example/memcached-operator
hack pkg/metrics: add an updater function to CreateServiceMonitors (#1991) Oct 18, 2019
images/scorecard-proxy Operator developers gets UBI8 based images (for all less Ansible) (#1952 Sep 27, 2019
internal Add labels to scorecard tests (#2079) Oct 18, 2019
pkg refactor(ansible): store relevant data on watch (#2067) Oct 18, 2019
test V1alpha2 api - scorecard output changes for v1alpha2 version (#1995) Oct 16, 2019
version *: bump to v0.11.0+git for master (#2052) Oct 12, 2019
.gitignore ci: run tests being run in prow CI in travis CI for non-master… (#1970) Oct 1, 2019
.travis.yml ci: run tests being run in prow CI in travis CI for non-master… (#1970) Oct 1, 2019
CHANGELOG.md V1alpha2 api - scorecard output changes for v1alpha2 version (#1995) Oct 16, 2019
CONTRIBUTING.MD contributing.md: require documentation for new features Jun 25, 2018
LICENSE Initial commit Feb 7, 2018
MAINTAINERS MAINTAINERS: update maintainers (#1147) Mar 1, 2019
Makefile ci: run tests being run in prow CI in travis CI for non-master… (#1970) Oct 1, 2019
OWNERS add jmccormick2001 to OWNERS file (#1880) Sep 5, 2019
README.md Add Operator capability level image in the README (#2070) Oct 16, 2019
bill-of-materials.json *: update import paths from coreos to operator-framework Apr 27, 2018
bill-of-materials.override.json pom: add bill-of-materials.override.json Mar 16, 2018
code-of-conduct.md operator-sdk: add code-of-conduct.md Apr 26, 2018
go.mod V1alpha2 api - scorecard output changes for v1alpha2 version (#1995) Oct 16, 2019
go.sum V1alpha2 api - scorecard output changes for v1alpha2 version (#1995) Oct 16, 2019
release.sh *: release v0.10.0 (#1800) Aug 8, 2019

README.md

Build Status License Go Report Card

Overview

This project is a component of the Operator Framework, an open source toolkit to manage Kubernetes native applications, called Operators, in an effective, automated, and scalable way. Read more in the introduction blog post.

Operators make it easy to manage complex stateful applications on top of Kubernetes. However writing an operator today can be difficult because of challenges such as using low level APIs, writing boilerplate, and a lack of modularity which leads to duplication.

The Operator SDK is a framework that uses the controller-runtime library to make writing operators easier by providing:

  • High level APIs and abstractions to write the operational logic more intuitively
  • Tools for scaffolding and code generation to bootstrap a new project fast
  • Extensions to cover common operator use cases

Workflow

The SDK provides workflows to develop operators in Go, Ansible, or Helm.

The following workflow is for a new Go operator:

  1. Create a new operator project using the SDK Command Line Interface(CLI)
  2. Define new resource APIs by adding Custom Resource Definitions(CRD)
  3. Define Controllers to watch and reconcile resources
  4. Write the reconciling logic for your Controller using the SDK and controller-runtime APIs
  5. Use the SDK CLI to build and generate the operator deployment manifests

The following workflow is for a new Ansible operator:

  1. Create a new operator project using the SDK Command Line Interface(CLI)
  2. Write the reconciling logic for your object using ansible playbooks and roles
  3. Use the SDK CLI to build and generate the operator deployment manifests
  4. Optionally add additional CRD's using the SDK CLI and repeat steps 2 and 3

The following workflow is for a new Helm operator:

  1. Create a new operator project using the SDK Command Line Interface(CLI)
  2. Create a new (or add your existing) Helm chart for use by the operator's reconciling logic
  3. Use the SDK CLI to build and generate the operator deployment manifests
  4. Optionally add additional CRD's using the SDK CLI and repeat steps 2 and 3

Prerequisites

  • git
  • go version v1.12+.
  • mercurial version 3.9+
  • docker version 17.03+.
  • kubectl version v1.11.3+.
  • Access to a Kubernetes v1.11.3+ cluster.
  • Optional: dep version v0.5.0+.
  • Optional: delve version 1.2.0+ (for up local --enable-delve).

Quick Start

Install the Operator SDK CLI

Follow the steps in the installation guide to learn how to install the Operator SDK CLI tool.

Note: If you are using a release version of the SDK, make sure to follow the documentation for that version. e.g.: For version 0.8.1, see docs in https://github.com/operator-framework/operator-sdk/tree/v0.8.1.

Create and deploy an app-operator

# Create an app-operator project that defines the App CR.
$ mkdir -p $HOME/projects/example-inc/
# Create a new app-operator project
$ cd $HOME/projects/example-inc/
$ export GO111MODULE=on
$ operator-sdk new app-operator --repo github.com/example-inc/app-operator
$ cd app-operator

# Add a new API for the custom resource AppService
$ operator-sdk add api --api-version=app.example.com/v1alpha1 --kind=AppService

# Add a new controller that watches for AppService
$ operator-sdk add controller --api-version=app.example.com/v1alpha1 --kind=AppService

# Build and push the app-operator image to a public registry such as quay.io
$ operator-sdk build quay.io/example/app-operator
$ docker push quay.io/example/app-operator

# Update the operator manifest to use the built image name (if you are performing these steps on OSX, see note below)
$ sed -i 's|REPLACE_IMAGE|quay.io/example/app-operator|g' deploy/operator.yaml
# On OSX use:
$ sed -i "" 's|REPLACE_IMAGE|quay.io/example/app-operator|g' deploy/operator.yaml

# Setup Service Account
$ kubectl create -f deploy/service_account.yaml
# Setup RBAC
$ kubectl create -f deploy/role.yaml
$ kubectl create -f deploy/role_binding.yaml
# Setup the CRD
$ kubectl create -f deploy/crds/app.example.com_appservices_crd.yaml
# Deploy the app-operator
$ kubectl create -f deploy/operator.yaml

# Create an AppService CR
# The default controller will watch for AppService objects and create a pod for each CR
$ kubectl create -f deploy/crds/app.example.com_v1alpha1_appservice_cr.yaml

# Verify that a pod is created
$ kubectl get pod -l app=example-appservice
NAME                     READY     STATUS    RESTARTS   AGE
example-appservice-pod   1/1       Running   0          1m

# Test the new Resource Type
$ kubectl describe appservice example-appservice
Name:         example-appservice
Namespace:    myproject
Labels:       <none>
Annotations:  <none>
API Version:  app.example.com/v1alpha1
Kind:         AppService
Metadata:
  Cluster Name:        
  Creation Timestamp:  2018-12-17T21:18:43Z
  Generation:          1
  Resource Version:    248412
  Self Link:           /apis/app.example.com/v1alpha1/namespaces/myproject/appservices/example-appservice
  UID:                 554f301f-0241-11e9-b551-080027c7d133
Spec:
  Size:  3

# Cleanup
$ kubectl delete -f deploy/crds/app.example.com_v1alpha1_appservice_cr.yaml
$ kubectl delete -f deploy/operator.yaml
$ kubectl delete -f deploy/role.yaml
$ kubectl delete -f deploy/role_binding.yaml
$ kubectl delete -f deploy/service_account.yaml
$ kubectl delete -f deploy/crds/app.example.com_appservices_crd.yaml

Note: Follow the steps in the Getting Started Repository to learn how to develop your Operator projects.

Command Line Interface

To learn more about the SDK CLI, see the SDK CLI Reference, or run operator-sdk [command] -h.

User Guides

To learn more about the writing an operator in Go, see the user guide.

The SDK also supports developing an operator using Ansible or Helm. See the Ansible and Helm operator user guides.

Operator capability level

Note that each operator type has a different set of capabilities. When choosing what type to use for your project, it is important to understand the features and limitations of each of the project types and the use cases for your operator.

operator-capability-level

Samples

To explore any operator samples built using the operator-sdk, see the operator-sdk-samples.

FAQ

For common Operator SDK related questions, see the FAQ.

Contributing

See CONTRIBUTING for details on submitting patches and the contribution workflow.

See the proposal docs and issues for ongoing or planned work.

Reporting bugs

See reporting bugs for details about reporting any issues.

License

Operator SDK is under Apache 2.0 license. See the LICENSE file for details.

You can’t perform that action at this time.