djzager.hello_world_k8s
Ansible Role: Hello World Kubernetes
This role manages a simple "Hello World" application in Kubernetes or OpenShift. It also allows you to deploy it using Ansible Operator in your Kubernetes or OpenShift cluster.
Requirements
- Ansible version 2.6 or higher
- OpenShift Python package
Role Variables
Check out the variable settings in defaults/main.yml.
Dependencies
There are no dependencies.
Example Playbook
NOTE This example assumes you have a running Kubernetes or OpenShift cluster and the right permissions in the my-hello-world-namespace
.
- hosts: localhost
vars:
name: my-hello-world
namespace: my-hello-world-namespace
size: 3
roles:
- djzager.hello_world_k8s
Example Operator
NOTE This example assumes you have admin access to the Kubernetes or OpenShift cluster because you will create a Role, Service Accounts Role Binding, and a Custom Resource Definition.
First, build your operator using operator-sdk
. You can find it here:
$ operator-sdk build hello-world-operator
Next, create the necessary objects for your operator:
$ kubectl create -f deploy/service_account.yaml \
-f deploy/role.yaml \
-f deploy/role_binding.yaml \
-f deploy/crds/examples_v1alpha1_helloworld_crd.yaml
Then, start the operator:
# Replace with the image name from the operator-sdk build step
# and set the imagePullPolicy to Never
$ sed 's|REPLACE_IMAGE|hello-world-operator|g; s|Always|Never|' deploy/operator.yaml | kubectl create -f -
Finally, create a HelloWorld resource:
$ kubectl create -f deploy/crds/examples_v1alpha1_helloworld_cr.yaml
Manage hello-world application in Kubernetes|OpenShift
ansible-galaxy install djzager.hello_world_k8s