diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml new file mode 100644 index 00000000..caad7109 --- /dev/null +++ b/charts/microservice/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: microservice +description: A Helm chart for a microservice in Kubernetes + +type: application +version: 0.1.0 +appVersion: "1.0" diff --git a/charts/microservice/README.md b/charts/microservice/README.md new file mode 100644 index 00000000..ddcf4c67 --- /dev/null +++ b/charts/microservice/README.md @@ -0,0 +1,24 @@ +# Basic Helm Template for Deploying Microservice on K8s + +## Chart Structure +``` +microservice/ +├── Chart.yaml +├── values.yaml +├── charts/ +└── templates/ + ├── deployment.yaml + └── service.yaml +``` + +## Usage + +You can change the Docker image by modifying the values.yaml file. For example, to use a different image, update the `image.repository` and `image.tag` fields. + +The Helm chart is specifically for deploying a microservice with a Kubernetes service and deployment. You can further customize and expand this chart as needed for your application. + +## Installing the Chart on K8s + +```bash +helm install my-release microservice/ +``` \ No newline at end of file diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml new file mode 100644 index 00000000..13f013f7 --- /dev/null +++ b/charts/microservice/templates/deployment.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "microservice.fullname" . }} + labels: + {{- include "microservice.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "microservice.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "microservice.selectorLabels" . | nindent 8 }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP diff --git a/charts/microservice/templates/service.yaml b/charts/microservice/templates/service.yaml new file mode 100644 index 00000000..1ace41b7 --- /dev/null +++ b/charts/microservice/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "microservice.fullname" . }} + labels: + {{- include "microservice.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "microservice.selectorLabels" . | nindent 4 }} diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml new file mode 100644 index 00000000..67e2ed03 --- /dev/null +++ b/charts/microservice/values.yaml @@ -0,0 +1,10 @@ +replicaCount: 1 + +image: + repository: nginx # your microservice image name + pullPolicy: IfNotPresent + tag: "latest" # your microservice image tag + +service: + type: ClusterIP + port: 80