Skip to content

mateothegreat/k8-byexamples-rabbitmq-cluster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clickity click Twitter Follow Skype Contact

Kubernetes @ RabbitMQ 3.7 Cluster using Peer Discovery

can you hear me now?

k8 by example -- straight to the point, simple execution.

Usage

Usage:

    make <target>
    
Targets:

    build                Build docker image
    push-gcloud          Push docker image using `gcloud`
    scale                Scale rabbitmq pods from the stateful set (make scale REPLICAS=3)
    manifests            Output manifests detected (used with make install, delete, get, describe, etc)
    install              Installs manifests to kubernetes using kubectl apply (make manifests to see what will be installed)
    delete               Deletes manifests to kubernetes using kubectl delete (make manifests to see what will be installed)
    get                  Retrieves manifests to kubernetes using kubectl get (make manifests to see what will be installed)
    describe             Describes manifests to kubernetes using kubectl describe (make manifests to see what will be installed)
    context              Globally set the current-context (default namespace)
    shell                Grab a shell in a running container

Install

Make sure to run git submodule update --init first.

$ make install

[ INSTALLING MANIFESTS/DEPLOYMENT.YAML ]: deployment "rabbitmq" created
[ INSTALLING MANIFESTS/SERVICE.YAML ]: service "rabbitmq" created
[ INSTALLING MANIFESTS/CONFIGMAP.YAML ]: configmap "rabbitmq-config" created
[ INSTALLING MANIFESTS/STATEFULSET.YAML ]: statefulset "rabbitmq" created
[ INSTALLING MANIFESTS/RBAC-SERVICEACCOUNT.YAML ]: serviceaccount "rabbitmq" created
[ INSTALLING MANIFESTS/RBAC-ROLE.YAML ]: role "endpoint-reader" created
[ INSTALLING MANIFESTS/RBAC-ROLEBINDING.YAML ]: rolebinding "endpoint-reader" created

Now you can open your browser to http://rabbitmq:15672 (user/pass = guest).

Adding a user

$ make adduser

kubectl exec rabbitmq-0 -it -- rabbitmqctl add_user admin P@55w0rd!!
Adding user "admin" ...
kubectl exec rabbitmq-0 -it -- rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...
kubectl exec rabbitmq-0 -it -- rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
Setting permissions for user "admin" in vhost "/" ...

Scaling

[yomateo@instance-1 k8-byexamples-rabbitmq-cluster]$ make scale REPLICAS=3
kubectl scale statefulset/rabbitmq --namespace=default --replicas=3
statefulset "rabbitmq" scaled

[yomateo@instance-1 k8-byexamples-rabbitmq-cluster]$ make kube/logs

2018-02-17 11:36:57.086 [info] <0.373.0> rabbit on node '[email protected]' up
2018-02-17 11:37:13.371 [info] <0.373.0> node '[email protected]' up

2018-02-17 11:37:14.594 [info] <0.373.0> rabbit on node '[email protected]' up
2018-02-17 11:37:43.308 [info] <0.373.0> node '[email protected]' up

2018-02-17 11:37:45.329 [info] <0.373.0> rabbit on node '[email protected]' up
2018-02-17 11:40:00.459 [info] <0.373.0> node '[email protected]' up

Cleanup

$ make delete

[ DELETING MANIFESTS/DEPLOYMENT.YAML ]: deployment "rabbitmq" deleted
[ DELETING MANIFESTS/SERVICE.YAML ]: service "rabbitmq" deleted
[ DELETING MANIFESTS/CONFIGMAP.YAML ]: configmap "rabbitmq-config" deleted
[ DELETING MANIFESTS/STATEFULSET.YAML ]: statefulset "rabbitmq" deleted
[ DELETING MANIFESTS/RBAC-SERVICEACCOUNT.YAML ]: serviceaccount "rabbitmq" deleted
[ DELETING MANIFESTS/RBAC-ROLE.YAML ]: role "endpoint-reader" deleted
[ DELETING MANIFESTS/RBAC-ROLEBINDING.YAML ]: rolebinding "endpoint-reader" deleted

See also

Releases

No releases published

Packages

No packages published