This repository contains the Kubernetes operator code for example custom resource of WeatherReport
.
$ cd $GOPATH/src/github.com/onuryilmaz/
$operator-sdk new k8s-operator-example --api-version=k8s.packt.com/v1 --kind=WeatherReport
$ operator-sdk build onuryilmaz/k8s-operator-example
$ docker push onuryilmaz/k8s-operator-example
$ kubectl create -f deploy/crd.yaml
$ kubectl create -f deploy/operator.yaml
$ kubectl create -f deploy/cr.yaml
$ kubectl describe weatherreport amsterdam-daily
Name: amsterdam-daily
Namespace: default
…
API Version: k8s.packt.com/v1
Kind: WeatherReport
Metadata:
…
Spec:
City: Amsterdam
Days: 1
Status:
Pod: weather-report-259735700
State: Started
$ kubectl logs $(kubectl get weatherreport amsterdam-daily -o jsonpath={.status.pod})
Weather report: Amsterdam, Netherlands
\ / Partly cloudy
_ /"".-. 21 °C
\_( ). ↘ 19 km/h
/(___(__) 10 km
0.0 mm
$ kubectl delete -f deploy/cr.yaml
$ kubectl delete -f deploy/operator.yaml
$ kubectl delete -f deploy/rbac.yaml