kubernetes

kubernetes - naigos pod 설치

sysman 2021. 5. 22. 12:38

 

[root@master ~]# vi nagios.yml

---
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
---
apiVersion: v1
kind: Service
metadata:
  name: nagios-service
spec:
  type: NodePort
  selector:
    app: nagios-core
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30008

 

 

[root@master ~]# kubectl apply -f nagios.yml

deployment.apps/nagios-deployment created
service/nagios-service created

 

[root@master ~]# kubectl get pods
NAME                                 READY   STATUS    RESTARTS   AGE
nagios-deployment-6674945696-qrbgx   1/1     Running   0          2m46s
nginx-deployment-3-5d95ccf78-mvdbq   1/1     Running   0          46m

 

[root@master ~]# kubectl get svc
NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
kubernetes           ClusterIP   10.96.0.1       <none>        443/TCP        103m
nagios-service       NodePort    10.98.92.77     <none>        80:30008/TCP   2m59s
nodeport-service-3   NodePort    10.98.208.182   <none>        80:30502/TCP   47m

 

 

[root@master ~]# kubectl exec -it nagios-deployment-6674945696-qrbgx -- /bin/bash
root@nagios-deployment-6674945696-qrbgx:/#
root@nagios-deployment-6674945696-qrbgx:/#
root@nagios-deployment-6674945696-qrbgx:/# htpasswd /opt/nagios/etc/htpasswd.users root
New password: root
Re-type new password: root
Adding password for user root
root@nagios-deployment-6674945696-qrbgx:/#

 

접속확인

 

 

 

참고

https://www.nbtechsupport.co.in/2021/03/deploy-nagios-on-kubernetes.html