diff --git a/deployment/k8/README.md b/deployment/k8/README.md new file mode 100644 index 000000000..1c418ef9a --- /dev/null +++ b/deployment/k8/README.md @@ -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 +``` diff --git a/deployment/k8/migration-console/Chart.lock b/deployment/k8/migration-console/Chart.lock index 1157df320..2c411285e 100644 --- a/deployment/k8/migration-console/Chart.lock +++ b/deployment/k8/migration-console/Chart.lock @@ -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" diff --git a/deployment/k8/migration-console/Chart.yaml b/deployment/k8/migration-console/Chart.yaml index d97fe9a2e..4210da4af 100644 --- a/deployment/k8/migration-console/Chart.yaml +++ b/deployment/k8/migration-console/Chart.yaml @@ -8,5 +8,5 @@ dependencies: - name: migrations-lib version: "0.1.0" repository: "file://../migrations-lib" - import-values: - - "otelCollector" +# import-values: +# - "otelCollector" diff --git a/deployment/k8/migration-console/templates/deployment.yml b/deployment/k8/migration-console/templates/deployment.yml index 69f03feb3..a6f4c2f11 100644 --- a/deployment/k8/migration-console/templates/deployment.yml +++ b/deployment/k8/migration-console/templates/deployment.yml @@ -13,6 +13,8 @@ spec: metadata: labels: app: {{ .Chart.Name }} + annotations: + sidecar.opentelemetry.io/inject: "true" # CORRECT spec: containers: - name: {{ .Chart.Name }} @@ -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: diff --git a/deployment/k8/migrations-lib/templates/_otel-collector.yml b/deployment/k8/migrations-lib/templates/_otel-collector.yml index acd2e5eb1..e991ae747 100644 --- a/deployment/k8/migrations-lib/templates/_otel-collector.yml +++ b/deployment/k8/migrations-lib/templates/_otel-collector.yml @@ -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] diff --git a/deployment/k8/migrations-lib/values.yaml b/deployment/k8/migrations-lib/values.yaml index 8a81608a2..33a8239cc 100644 --- a/deployment/k8/migrations-lib/values.yaml +++ b/deployment/k8/migrations-lib/values.yaml @@ -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 diff --git a/deployment/k8/minikubeTool.sh b/deployment/k8/minikubeLocal.sh similarity index 100% rename from deployment/k8/minikubeTool.sh rename to deployment/k8/minikubeLocal.sh