Deploy Nagios on Kubernetes Kodekloud

 

Question: The Nautilus DevOps team is planning to set up a Nagios monitoring tool to monitor some applications, services etc. They are planning to deploy it on Kubernetes cluster. Below you can find more details.

1) Create a deployment nagios-deployment for Nagios core. The container name must be nagios-container and it must use jasonrivers/nagios image.

2) Create a user and password for the Nagios core web interface, user must be xFusionCorp and password must be LQfKeWWxWD. (you can manually perform this step after deployment)

3) Create a service nagios-service for Nagios, which must be of targetPort type. nodePort must be 30008.

You can use any labels as per your choice.

Note: The kubectl on jump_host has been configured to work with the kubernetes cluster.


Solution:

Create deployment.yaml and service.yaml according to question

vi deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
name: nagios-deployment
spec:
replicas: 1
selector:
matchLabels:
app: nagios-core
template:
metadata:
labels:
app: nagios-core
spec:
containers:
- name: nagios-container
image: jasonrivers/nagios

 vi service.yaml

apiVersion: v1
kind: Service
metadata:
name: nagios-service
spec:
type: NodePort
selector:
app: nagios-core
ports:
- port: 80
targetPort: 80
nodePort: 30008

Then apply 

kubectl apply -f .

Next, exec into pod

kubectl exec -it pod-name /bin/bash

Create the username and password according to question

htpasswd /opt/nagios/etc/htpasswd.users xFusionCorp

Finally, Click on Nagios button from the right side. You can see the nagios dashboard.


 

 





Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment