Skip to content

Commit

Permalink
Add documentation for getting started with K8 and minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: Tanner Lewis <[email protected]>
  • Loading branch information
lewijacn committed Oct 22, 2024
1 parent 8614014 commit e174444
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 46 deletions.
85 changes: 85 additions & 0 deletions deployment/k8/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Kubernetes Deployment

## Prerequisites

#### Install kubectl
Follow instructions [here](https://kubernetes.io/docs/tasks/tools/) to install the Kubernetes command-line tool. This will be the go-to tool for interacting with the Kubernetes cluster

#### Install helm
Follow instructions [here](https://helm.sh/docs/intro/install/) to install helm. helm will be used for deploying to the Kubernetes cluster

#### Install docker
Follow instructions [here](https://docs.docker.com/engine/install/) to set up Docker. Docker will be used to build Docker images as well as run a local Kubernetes cluster. Later versions are recommended.


## Local Kubernetes Cluster
Creating a local Kubernetes cluster is useful for testing and developing a given deployment. There are a few different tools for running a Kubernetes cluster locally. This documentation focuses on using [Minikube](https://github.com/kubernetes/minikube) to run the local Kubernetes cluster.

### Install Minikube
Follow instructions [here](https://minikube.sigs.k8s.io/docs/start/?arch=%2Fmacos%2Fx86-64%2Fstable%2Fbinary+download) to install Minikube

### Loading Docker images into Minikube
Since Minikube uses a different Docker registry than the normal host machine, the Docker images shown will differ from that on the host machine. The script `buildDockerImagesMini.sh` in this directory will configure the environment to use the Minikube Docker registry and build the Docker images into Minikube

Show Docker images available to Minikube
```shell
minikube image ls
```
Build Docker images into Minikube
```shell
./buildDockerImagesMini.sh
```

### Start/Pause/Delete
A convenience script `minikubeLocal.sh` is located in this directory which wraps the Minikube commands to start/pause/delete Minikube. This is useful for automatically handling items such as mounting the local repo and creating a tunnel to make localhost calls to containers
```shell
./miniKubeLocal.sh --start
./miniKubeLocal.sh --pause
./miniKubeLocal.sh --delete
```


## Deploying

### Full environment
Guide for deploying a complete environment helm chart comprised of many Migration service helm charts

The full environment helm charts consists of:
* Source cluster
* Target cluster
* Migration services

**Note**: For first-time deployments and deployments after changes have been made to a dependent helm package, such as the `migration-console` chart, the following command is needed to update dependent charts
```shell
helm dependency update environments/full-environment
```

The full environment helm chart can be deployed with the helm command
```shell
helm install local environments/full-environment
```

### Specific services
Guide for deploying an individual Migration service helm chart

Most migration services have a dependency on Persistent Volumes that can be installed to the Kubernetes cluster using the following commands
```shell
helm install shared-logs shared/shared-logs-vol
helm install snapshot-vol shared/snapshot-vol
```

A particular service could then be deployed with a command similar to the below.
```shell
helm install migration-console migration-console
```

## Uninstalling
To show all helm deployments
```shell
helm list
```

To uninstall a particular helm deployment
```shell
helm uninstall <deployment_name>
```
4 changes: 2 additions & 2 deletions deployment/k8/migration-console/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ dependencies:
- name: migrations-lib
repository: file://../migrations-lib
version: 0.1.0
digest: sha256:16ba79c267bb045bbee80921a6d838f88f8bd9d4d7d2549b82ac700691a91236
generated: "2024-10-19T00:23:01.6744-05:00"
digest: sha256:7d5c25e2ed7da25adb550d420edcd8fbb2793d966da650dfbb68265aea5ca41e
generated: "2024-10-21T14:49:22.624024-05:00"
4 changes: 2 additions & 2 deletions deployment/k8/migration-console/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ dependencies:
- name: migrations-lib
version: "0.1.0"
repository: "file://../migrations-lib"
import-values:
- "otelCollector"
# import-values:
# - "otelCollector"
3 changes: 2 additions & 1 deletion deployment/k8/migration-console/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ spec:
metadata:
labels:
app: {{ .Chart.Name }}
annotations:
sidecar.opentelemetry.io/inject: "true" # CORRECT
spec:
containers:
- name: {{ .Chart.Name }}
Expand All @@ -31,7 +33,6 @@ spec:
mountPath: {{ .Values.servicesYamlVolume.mountPath }}
- name: {{ .Values.snapshotVolume.volumeName }}
mountPath: {{ .Values.snapshotVolume.mountPath }}
{{- include "migrations-lib.otel-sidecar" . | indent 8 }}
volumes:
- name: {{ .Values.sharedLogVolume.volumeName }}
persistentVolumeClaim:
Expand Down
36 changes: 21 additions & 15 deletions deployment/k8/migrations-lib/templates/_otel-collector.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{{- define "migrations-lib.otel-sidecar" -}}
- name: {{ .Values.otelCollector.name}}
image: "{{ .Values.otelCollector.image.repository }}:{{ .Values.otelCollector.image.tag }}"
imagePullPolicy: {{ .Values.otelCollector.image.pullPolicy }}
ports:
{{- range .Values.otelCollector.ports }}
- name: {{ .name }}
containerPort: {{ .containerPort }}
protocol: {{ .protocol | default "TCP" }}
{{- end }}
restartPolicy: {{ .Values.otelCollector.restartPolicy }}
{{- if .Values.otelCollector.args }}
args: {{ .Values.otelCollector.args }}
{{- end }}
{{- end }}
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
name: sidecar-for-my-app
spec:
mode: sidecar
config:
receivers:
jaeger:
protocols:
thrift_compact: {}
processors:

exporters:
debug: {}

service:
pipelines:
traces:
receivers: [jaeger]
exporters: [debug]
52 changes: 26 additions & 26 deletions deployment/k8/migrations-lib/values.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
otelCollector:
name: otel-collector
restartPolicy: "Always"
#args: "--config=/etc/otel-config-debug-only.yaml"
#args: ["--config=/etc/otel-config-prometheus-jaeger.yaml"]
image:
repository: migrations/otel_collector
pullPolicy: IfNotPresent
tag: "latest"
ports:
- name: pprof
containerPort: 1888
protocol: TCP
- name: health-check
containerPort: 13133
protocol: TCP
- name: zpages
containerPort: 55679
protocol: TCP
- name: otlp-receiver
containerPort: 4317
protocol: TCP
# - name: prom-metrics
# containerPort: 8888
#otelCollector:
# name: otel-collector
# restartPolicy: "Always"
# #args: "--config=/etc/otel-config-debug-only.yaml"
# #args: ["--config=/etc/otel-config-prometheus-jaeger.yaml"]
# image:
# repository: migrations/otel_collector
# pullPolicy: IfNotPresent
# tag: "latest"
# ports:
# - name: pprof
# containerPort: 1888
# protocol: TCP
# - name: prom-exporter
# containerPort: 8889
# - name: health-check
# containerPort: 13133
# protocol: TCP
# - name: zpages
# containerPort: 55679
# protocol: TCP
# - name: otlp-receiver
# containerPort: 4317
# protocol: TCP
## - name: prom-metrics
## containerPort: 8888
## protocol: TCP
## - name: prom-exporter
## containerPort: 8889
## protocol: TCP
File renamed without changes.

0 comments on commit e174444

Please sign in to comment.