Skip to content

A Kuberentes Operator using the operator-sdk project that deploys wordpress using on sql via a custom resource.

Notifications You must be signed in to change notification settings

simran2104/Wordpress-Operator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wordpress Operator

The Objective of this Operator is to demonstrate Wordpress kind of resource using Kuberentes controller pattern- Operator. Another objective of the repository is to show how to build the custom controller that encapsulates specific domain/application level knowledge. The Operator is built using the operator-sdk framework. If Wordpress and MySQL were to be deployed without operator on Kuberenetes, it can be referred here. Lets understand how can this be achieved via Kubernetes Operator.

Prerequistites

Wordpress Resource

The Wordpress Operator using the operator-sdk project deploys wordpress using on sql via a custom resource

  • A kubernetes resource of kind: Wordpress and apiVersion: example.com/v1 is created that results in the Operator deploying Deployments, PersistentVolumeClaims, Services, that constitute a simple instance of wordpress on sql.
  • The user can specify plaintext password that can be used as a MYSQL_ROOT_PASSWORD. Once the user applies the Wordpress resource (kubectl aply -f ./deploy/crds/example.com_v1_wordpress_cr.yaml) resource, controller could spin up mysql and wordpress pods using the MYSQL_ROOT_PASSWORD as specified in spec.sqlrootpassword. e.g.,
apiVersion: example.com/v1
kind: Wordpress
metadata:
  name: mysite
spec:
  sqlRootPassword: plaintextpassword 

Trying the Operator

git clone https://github.com/simran2104/Wordpress-Operator.git cd Wordpress-Operator We would be trying out the operator locally. By locally we mean that we want to run the operatot logic binary without actually building an image and pushing it to a container registry. Running the operator locally helps in day to day development. You can have a minikube single node local cluster to play with the operator. Before running the operator do:

kubectl apply -f ./config/crd/bases/example.com_wordpresses.yaml

The CRD would be registerd and you can check that by the following command: kubectl get crd After that run the operator locally with operator-sdk run --local

See if the pods,deployments,pvcs and services are up and running:

kubectl get pods
kubectl get deploy
kubectl get pvc
kubectl get svc

You should be able to see the following output:

image

Run the following command to get the IP Address for the Wordpress Service:

minikube service wordpress --url

The response should be like this:

http://192.168.99.101:31881

Copy the IP address and load the page in your browser to view your site:

alt text

About

A Kuberentes Operator using the operator-sdk project that deploys wordpress using on sql via a custom resource.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published