netbox_deploy_v2
Differences
This shows you the differences between two versions of the page.
| netbox_deploy_v2 [2025/07/26 17:09] – - Imported by DokuWiki Advanced Plugin wikiadm | netbox_deploy_v2 [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Netbox Deployment v2 ====== | ||
| - | |||
| - | ===== Database PostgreSQL ===== | ||
| - | <file sql> | ||
| - | # CREATE ROLE netbox LOGIN; | ||
| - | # CREATE DATABASE netbox OWNER netbox; | ||
| - | # \password netbox | ||
| - | # \q | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ vim ${PGDATA}/ | ||
| - | [...] | ||
| - | # Acesso netbox Kubernetes | ||
| - | host netbox | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ pg_ctl reload | ||
| - | </ | ||
| - | |||
| - | ===== Database/ | ||
| - | <file bash> | ||
| - | $ helm repo add bitnami https:// | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ helm install redis bitnami/ | ||
| - | NAME: redis | ||
| - | LAST DEPLOYED: Thu Feb 2 10:24:00 2023 | ||
| - | NAMESPACE: netbox | ||
| - | STATUS: deployed | ||
| - | REVISION: 1 | ||
| - | TEST SUITE: None | ||
| - | NOTES: | ||
| - | CHART NAME: redis | ||
| - | CHART VERSION: 17.6.0 | ||
| - | APP VERSION: 7.0.8 | ||
| - | |||
| - | ** Please be patient while the chart is being deployed ** | ||
| - | |||
| - | Redis& | ||
| - | |||
| - | redis-master.netbox.svc.cluster.local for read/write operations (port 6379) | ||
| - | redis-replicas.netbox.svc.cluster.local for read-only operations (port 6379) | ||
| - | |||
| - | |||
| - | |||
| - | To get your password run: | ||
| - | |||
| - | export REDIS_PASSWORD=$(kubectl get secret --namespace netbox redis -o jsonpath=" | ||
| - | |||
| - | To connect to your Redis& | ||
| - | |||
| - | 1. Run a Redis& | ||
| - | |||
| - | | ||
| - | |||
| - | Use the following command to attach to the pod: | ||
| - | |||
| - | | ||
| - | | ||
| - | |||
| - | 2. Connect using the Redis& | ||
| - | | ||
| - | | ||
| - | |||
| - | To connect to your database from outside the cluster execute the following commands: | ||
| - | |||
| - | kubectl port-forward --namespace netbox svc/ | ||
| - | REDISCLI_AUTH=" | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl get all -n netbox | ||
| - | NAME | ||
| - | pod/ | ||
| - | pod/ | ||
| - | pod/ | ||
| - | pod/ | ||
| - | |||
| - | NAME | ||
| - | service/ | ||
| - | service/ | ||
| - | service/ | ||
| - | |||
| - | NAME READY AGE | ||
| - | statefulset.apps/ | ||
| - | statefulset.apps/ | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl get pvc -n netbox | ||
| - | NAME STATUS | ||
| - | redis-data-redis-master-0 | ||
| - | redis-data-redis-replicas-0 | ||
| - | redis-data-redis-replicas-1 | ||
| - | redis-data-redis-replicas-2 | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl get cm -n netbox | ||
| - | NAME DATA AGE | ||
| - | kube-root-ca.crt | ||
| - | redis-configuration | ||
| - | redis-health | ||
| - | redis-scripts | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl get secret -n netbox | ||
| - | NAME TYPE DATA AGE | ||
| - | default-token-g7579 | ||
| - | redis | ||
| - | redis-token-brk6n | ||
| - | sh.helm.release.v1.redis.v1 | ||
| - | </ | ||
| - | |||
| - | ===== Netbox ===== | ||
| - | ==== ConfigMap ==== | ||
| - | <file yaml netbox-cm.yaml> | ||
| - | apiVersion: v1 | ||
| - | data: | ||
| - | DB_HOST: pgsql.juntotelecom.com.br | ||
| - | DB_NAME: netbox | ||
| - | DB_PORT: " | ||
| - | DB_USER: netbox | ||
| - | REDIS_HOST: redis-master | ||
| - | REDIS_PORT: " | ||
| - | REDIS_SSL: " | ||
| - | kind: ConfigMap | ||
| - | metadata: | ||
| - | annotations: | ||
| - | meta.helm.sh/ | ||
| - | meta.helm.sh/ | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | name: netbox | ||
| - | namespace: netbox | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl apply -f netbox-cm.yaml | ||
| - | </ | ||
| - | |||
| - | <file yaml netbox-cm-config.yaml> | ||
| - | apiVersion: v1 | ||
| - | data: | ||
| - | nginx.conf: |- | ||
| - | daemon off; | ||
| - | worker_processes 1; | ||
| - | |||
| - | error_log /dev/stderr info; | ||
| - | |||
| - | events { | ||
| - | worker_connections 1024; | ||
| - | } | ||
| - | |||
| - | http { | ||
| - | include | ||
| - | default_type | ||
| - | sendfile | ||
| - | tcp_nopush | ||
| - | keepalive_timeout | ||
| - | gzip on; | ||
| - | server_tokens | ||
| - | client_max_body_size 10M; | ||
| - | |||
| - | upstream netbox { | ||
| - | server localhost: | ||
| - | } | ||
| - | |||
| - | server { | ||
| - | listen | ||
| - | access_log | ||
| - | |||
| - | location /static/ { | ||
| - | alias / | ||
| - | } | ||
| - | |||
| - | location / { | ||
| - | proxy_pass http:// | ||
| - | proxy_set_header X-Forwarded-Host $http_host; | ||
| - | proxy_set_header X-Real-IP $remote_addr; | ||
| - | proxy_set_header X-Forwarded-Proto $scheme; | ||
| - | add_header P3P ' | ||
| - | } | ||
| - | } | ||
| - | |||
| - | server { | ||
| - | listen | ||
| - | access_log | ||
| - | |||
| - | location = / | ||
| - | stub_status; | ||
| - | } | ||
| - | } | ||
| - | } | ||
| - | kind: ConfigMap | ||
| - | metadata: | ||
| - | annotations: | ||
| - | meta.helm.sh/ | ||
| - | meta.helm.sh/ | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | name: netbox-config-files | ||
| - | namespace: netbox | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl apply -f netbox-cm-config.yaml | ||
| - | </ | ||
| - | |||
| - | ==== Secret ==== | ||
| - | <file yaml netbox-secret.yaml> | ||
| - | apiVersion: v1 | ||
| - | data: | ||
| - | SECRET_KEY: ZGgxczBSUHg4MG1LTVBjRXN2Ukx3eDllS1A4bHNZTzFiN01jdmwwdk94aFlBbEFzSjU= | ||
| - | kind: Secret | ||
| - | metadata: | ||
| - | annotations: | ||
| - | meta.helm.sh/ | ||
| - | meta.helm.sh/ | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | name: netbox | ||
| - | namespace: netbox | ||
| - | type: Opaque | ||
| - | </ | ||
| - | |||
| - | |||
| - | <file bash> | ||
| - | $ kubectl apply -f netbox-secret.yaml | ||
| - | </ | ||
| - | |||
| - | <file yaml netbox-secret-postgres.yaml> | ||
| - | apiVersion: v1 | ||
| - | data: | ||
| - | postgres-password: | ||
| - | kind: Secret | ||
| - | metadata: | ||
| - | annotations: | ||
| - | meta.helm.sh/ | ||
| - | meta.helm.sh/ | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | name: netbox-postgresql | ||
| - | namespace: netbox | ||
| - | type: Opaque | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl apply -f netbox-secret-postgres.yaml | ||
| - | </ | ||
| - | |||
| - | ==== persistentVolumeClaim ==== | ||
| - | <file yaml netbox-pvc.yaml> | ||
| - | apiVersion: v1 | ||
| - | kind: PersistentVolumeClaim | ||
| - | metadata: | ||
| - | annotations: | ||
| - | meta.helm.sh/ | ||
| - | meta.helm.sh/ | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | name: netbox | ||
| - | namespace: netbox | ||
| - | spec: | ||
| - | accessModes: | ||
| - | - ReadWriteOnce | ||
| - | resources: | ||
| - | requests: | ||
| - | storage: 10Gi | ||
| - | storageClassName: | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl apply -f netbox-pvc.yaml | ||
| - | </ | ||
| - | |||
| - | ==== Deployment ==== | ||
| - | <file yaml netbox-worker-deployment.yaml> | ||
| - | apiVersion: apps/v1 | ||
| - | kind: Deployment | ||
| - | metadata: | ||
| - | annotations: | ||
| - | deployment.kubernetes.io/ | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | name: netbox-worker | ||
| - | namespace: netbox | ||
| - | spec: | ||
| - | selector: | ||
| - | matchLabels: | ||
| - | app.kubernetes.io/ | ||
| - | template: | ||
| - | metadata: | ||
| - | annotations: | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | spec: | ||
| - | containers: | ||
| - | - command: | ||
| - | - / | ||
| - | - / | ||
| - | - rqworker | ||
| - | env: | ||
| - | - name: REDIS_PASSWORD | ||
| - | valueFrom: | ||
| - | secretKeyRef: | ||
| - | key: redis-password | ||
| - | name: redis | ||
| - | - name: DB_PASSWORD | ||
| - | valueFrom: | ||
| - | secretKeyRef: | ||
| - | key: postgres-password | ||
| - | name: netbox-postgresql | ||
| - | envFrom: | ||
| - | - configMapRef: | ||
| - | name: netbox | ||
| - | - secretRef: | ||
| - | name: netbox | ||
| - | image: netboxcommunity/ | ||
| - | imagePullPolicy: | ||
| - | name: netbox-worker | ||
| - | resources: {} | ||
| - | restartPolicy: | ||
| - | securityContext: | ||
| - | </ | ||
| - | |||
| - | <file yaml netbox-deployment.yaml> | ||
| - | apiVersion: apps/v1 | ||
| - | kind: Deployment | ||
| - | metadata: | ||
| - | annotations: | ||
| - | deployment.kubernetes.io/ | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | name: netbox | ||
| - | namespace: netbox | ||
| - | spec: | ||
| - | selector: | ||
| - | matchLabels: | ||
| - | app.kubernetes.io/ | ||
| - | template: | ||
| - | metadata: | ||
| - | annotations: | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | spec: | ||
| - | containers: | ||
| - | - env: | ||
| - | - name: REDIS_PASSWORD | ||
| - | valueFrom: | ||
| - | secretKeyRef: | ||
| - | key: redis-password | ||
| - | name: redis | ||
| - | - name: DB_PASSWORD | ||
| - | valueFrom: | ||
| - | secretKeyRef: | ||
| - | key: postgres-password | ||
| - | name: netbox-postgresql | ||
| - | envFrom: | ||
| - | - configMapRef: | ||
| - | name: netbox | ||
| - | - secretRef: | ||
| - | name: netbox | ||
| - | image: netboxcommunity/ | ||
| - | imagePullPolicy: | ||
| - | name: netbox | ||
| - | ports: | ||
| - | - containerPort: | ||
| - | name: http | ||
| - | protocol: TCP | ||
| - | resources: {} | ||
| - | volumeMounts: | ||
| - | - mountPath: / | ||
| - | name: data | ||
| - | restartPolicy: | ||
| - | securityContext: | ||
| - | volumes: | ||
| - | - configMap: | ||
| - | defaultMode: | ||
| - | name: netbox-config-files | ||
| - | name: netbox-config-files | ||
| - | - name: data | ||
| - | persistentVolumeClaim: | ||
| - | claimName: netbox | ||
| - | </ | ||
| - | |||
| - | <file yaml netbox-housekeeping-deployment.yaml> | ||
| - | apiVersion: apps/v1 | ||
| - | kind: Deployment | ||
| - | metadata: | ||
| - | annotations: | ||
| - | deployment.kubernetes.io/ | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | name: netbox-housekeeping | ||
| - | namespace: netbox | ||
| - | spec: | ||
| - | selector: | ||
| - | matchLabels: | ||
| - | app.kubernetes.io/ | ||
| - | template: | ||
| - | metadata: | ||
| - | annotations: | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | spec: | ||
| - | containers: | ||
| - | - command: | ||
| - | - / | ||
| - | env: | ||
| - | - name: REDIS_PASSWORD | ||
| - | valueFrom: | ||
| - | secretKeyRef: | ||
| - | key: redis-password | ||
| - | name: redis | ||
| - | - name: DB_PASSWORD | ||
| - | valueFrom: | ||
| - | secretKeyRef: | ||
| - | key: postgres-password | ||
| - | name: netbox-postgresql | ||
| - | envFrom: | ||
| - | - configMapRef: | ||
| - | name: netbox | ||
| - | - secretRef: | ||
| - | name: netbox | ||
| - | image: netboxcommunity/ | ||
| - | imagePullPolicy: | ||
| - | name: netbox-housekeeping | ||
| - | resources: {} | ||
| - | restartPolicy: | ||
| - | securityContext: | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl apply -f netbox-worker-deployment.yaml -f netbox-deployment.yaml -f netbox-housekeeping-deployment.yaml | ||
| - | </ | ||
| - | |||
| - | ==== Service ==== | ||
| - | <file yaml netbox-svc.yaml> | ||
| - | apiVersion: v1 | ||
| - | kind: Service | ||
| - | metadata: | ||
| - | annotations: | ||
| - | meta.helm.sh/ | ||
| - | meta.helm.sh/ | ||
| - | labels: | ||
| - | app.kubernetes.io/ | ||
| - | name: netbox | ||
| - | namespace: netbox | ||
| - | spec: | ||
| - | ipFamilies: | ||
| - | - IPv4 | ||
| - | - IPv6 | ||
| - | ipFamilyPolicy: | ||
| - | ports: | ||
| - | - name: http | ||
| - | port: 80 | ||
| - | protocol: TCP | ||
| - | targetPort: http | ||
| - | selector: | ||
| - | app.kubernetes.io/ | ||
| - | sessionAffinity: | ||
| - | type: ClusterIP | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl apply -f netbox-svc.yaml | ||
| - | </ | ||
| - | |||
| - | ==== Ingress ==== | ||
| - | <file yaml netbox-ingress.yaml> | ||
| - | apiVersion: networking.k8s.io/ | ||
| - | kind: Ingress | ||
| - | metadata: | ||
| - | name: netbox | ||
| - | namespace: netbox | ||
| - | spec: | ||
| - | ingressClassName: | ||
| - | rules: | ||
| - | - host: netbox.juntotelecom.com.br | ||
| - | http: | ||
| - | paths: | ||
| - | - backend: | ||
| - | service: | ||
| - | name: netbox | ||
| - | port: | ||
| - | number: 80 | ||
| - | path: / | ||
| - | pathType: Prefix | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl apply -f netbox-ingress.yaml | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ kubectl get all -n netbox | ||
| - | NAME | ||
| - | pod/ | ||
| - | pod/ | ||
| - | pod/ | ||
| - | pod/ | ||
| - | pod/ | ||
| - | pod/ | ||
| - | pod/ | ||
| - | |||
| - | NAME | ||
| - | service/ | ||
| - | service/ | ||
| - | service/ | ||
| - | service/ | ||
| - | |||
| - | NAME READY | ||
| - | deployment.apps/ | ||
| - | deployment.apps/ | ||
| - | deployment.apps/ | ||
| - | |||
| - | NAME | ||
| - | replicaset.apps/ | ||
| - | replicaset.apps/ | ||
| - | replicaset.apps/ | ||
| - | |||
| - | NAME READY AGE | ||
| - | statefulset.apps/ | ||
| - | statefulset.apps/ | ||
| - | </ | ||
netbox_deploy_v2.1753560544.txt.gz · Last modified: by wikiadm
