Go (golang) operator for Kubernetes.
Here's what you need to do if you just want to install this 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 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
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 |
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.
- Fork it (https://github.com/craicoverflow/golang-operator/fork)
- Create your feature branch (
git checkout -b fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin fooBar
) - Create a new Pull Request