NetBox Chart 开源项目教程
netbox-chartA Helm chart for NetBox项目地址:https://gitcode.com/gh_mirrors/net/netbox-chart
1. 项目的目录结构及介绍
NetBox Chart 项目的目录结构如下:
netbox-chart/
├── Chart.yaml
├── README.md
├── templates/
│ ├── NOTES.txt
│ ├── _helpers.tpl
│ ├── deployment.yaml
│ ├── ingress.yaml
│ ├── pvc.yaml
│ ├── secrets.yaml
│ ├── service.yaml
│ └── serviceaccount.yaml
└── values.yaml
目录结构介绍
Chart.yaml
: 包含Chart的基本信息,如名称、版本等。README.md
: 项目的说明文档。templates/
: 包含Kubernetes资源配置文件的模板。NOTES.txt
: 安装后显示的提示信息。_helpers.tpl
: 模板助手,用于定义通用的模板函数。deployment.yaml
: 定义NetBox的部署配置。ingress.yaml
: 定义Ingress资源,用于外部访问。pvc.yaml
: 定义持久卷声明。secrets.yaml
: 定义敏感信息,如数据库密码等。service.yaml
: 定义服务配置。serviceaccount.yaml
: 定义服务账户。
values.yaml
: 包含Chart的默认配置值。
2. 项目的启动文件介绍
项目的启动文件主要是templates/deployment.yaml
,它定义了NetBox的部署配置。以下是该文件的关键部分:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "netbox.fullname" . }}
labels:
app: {{ template "netbox.name" . }}
chart: {{ template "netbox.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "netbox.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "netbox.name" . }}
release: {{ .Release.Name }}
spec:
serviceAccountName: {{ template "netbox.serviceAccountName" . }}
containers:
- name: netbox
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 8080
env:
- name: DATABASE_URL
value: {{ .Values.databaseUrl | quote }}
- name: REDIS_URL
value: {{ .Values.redisUrl | quote }}
volumeMounts:
- name: netbox-media-files
mountPath: /opt/netbox/netbox/media
volumes:
- name: netbox-media-files
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim | default (include "netbox.fullname" .) }}
启动文件介绍
apiVersion
和kind
: 定义资源的API版本和类型。metadata
: 定义部署的元数据,如名称和标签。spec
: 定义部署的详细配置,包括副本数量、选择器、模板等。containers
: 定义容器配置,包括镜像、端口、环境变量和卷挂载。
3. 项目的配置文件介绍
项目的配置文件主要是values.yaml
,它包含了Chart的默认配置值。以下是该文件的关键部分:
replicaCount: 1
image:
repository: netboxcommunity/netbox
tag: "v2.10.4"
pullPolicy: IfNotPresent
databaseUrl: "postgres://netbox:netbox@netbox-postgresql/netbox"
redisUrl: "redis://netbox-redis:6379/0"
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {}
hosts:
- host: chart-example.local
paths: []
persistence:
enabled: true
existing
netbox-chartA Helm chart for NetBox项目地址:https://gitcode.com/gh_mirrors/net/netbox-chart