app-operator

module
v0.0.0-...-047e495 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2019 License: GPL-3.0

README

Kubernetes Operator

Built this thingy to get a grasp on operator-sdk & Go.

Description

Used the operator-sdk to generate all this scaffold code in Go.

Chosen Golang because I want to learn more about what this wonderful programming language can offer.

Workflow

  • start a Kubernetes cluster with kind
kind create cluster --config tests/kind/config.yaml

# export the KUBECONFIG variable to have access to the K8s cluster
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"

# is it working?
kubectl cluster-info

# tear-down cluster
kind delete cluster
  • apply the K8s stuff
# create ServiceAccount
kubectl create -f deploy/service_account.yaml

# setup RBAC
kubectl create -f deploy/role.yaml
kubectl create -f deploy/role_binding.yaml

# setup CRD
kubectl create -f deploy/crds/app_v1alpha1_appservice_crd.yaml

# deploy 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_v1alpha1_appservice_cr.yaml

# Verify that a pod is created
kubectl get pod -l app=example-appservice

# Cleanup
kubectl delete -f deploy/crds/app_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_v1alpha1_appservice_crd.yaml
What does it do?

ATM this Operator is not so useful - it's just a bogus operator. But in future it'll do something eventually, still need to decide on the scope.

FAQ

TBD

Troubleshoot

  • Error: a cluster with the name "kind" already exists

Sometimes you get this error if you created a cluster with kind before and eventhough you deleted it the thingy is still there. To solve this, just execute the delete command again: kind delete cluster and now you can proceed creating the K8s cluster.

  • error: SchemaError(io.k8s.api.core.v1.Container): invalid object doesn't have additional properties

This is thrown when trying to create the ServiceAccount via kubectl create -f deploy/service_account.yaml. Luckily there's a fix for that (on MacOS only unfortunately).

Directories

Path Synopsis
cmd
pkg
apis/app/v1alpha1
Package v1alpha1 contains API Schema definitions for the app v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=app.example.com
Package v1alpha1 contains API Schema definitions for the app v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=app.example.com

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL