Skip to content

craicoverflow/golang-operator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Operator

Go (golang) operator for Kubernetes.

Installation

Here's what you need to do if you just want to install this operator.

Build and run the operator

Before running the operator, the CRD must be registered with the Kubernetes apiserver:

kubectl apply -f deploy/crds/golang_v1alpha1_golang_crd.yaml

Setup RBAC and deploy the golang-operator:

kubectl apply -f deploy/service_account.yaml
kubectl apply -f deploy/role.yaml
kubectl apply -f deploy/role_binding.yaml
kubectl apply -f deploy/operator.yaml

Verify that the golang-operator is up and running:

> kubectl get deploy
NAME              DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
golang-operator   1         1         1            1           1m

Create a Golang CR

Create the example Golang CR that was generated at deploy/crds/golang_v1alpha1_golang_cr.yaml:

kubectl apply -f deploy/crd/golang_v1alpha1_golang_cr.yaml

Verify that the golang-operator creates the deployment for the CR:

> kubectl get deploy
NAME              DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
go-hello-world    1         1         1            1           3m
golang-operator   1         1         1            1           4m

Check the pods and CR status to confirm the status is updated with the golang pod names:

> kubectl get pods
NAME                               READY     STATUS    RESTARTS   AGE
go-hello-world-7c67d65476-9l6lk    1/1       Running   0          5m
golang-operator-5f4c5c675b-j7ff7   1/1       Running   1          6m

Customing the Golang CR

You can copy or customise the example CR to suit your own application.

Custom Property Description Required
spec.size The number of pods you wish to be created Yes
spec.image Docker image of your Go application Yes
spec.containerPort Port that your Docker application runs on No

Development setup

Install the Operator SDK CLI:

mkdir -p $GOPATH/src/github.com/operator-framework
cd $GOPATH/src/github.com/operator-framework
git clone https://github.com/operator-framework/operator-sdk
cd operator-sdk
git checkout master
make dep
make install

Refer to the Operator SDK User Guide for instructions on how to use and develop this project.

Contributing

  1. Fork it (https://github.com/craicoverflow/golang-operator/fork)
  2. Create your feature branch (git checkout -b fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin fooBar)
  5. Create a new Pull Request

About

Go (golang) operator for Kubernetes.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published