diff --git a/Makefile b/Makefile index d812a972..9a107ed8 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ ILAB_KUBE_CLUSTER_NAME?=instructlab-ui CONTAINER_ENGINE?=docker DEVCONTAINER_BINARY_EXISTS ?= $(shell command -v devcontainer) TAG=$(shell git rev-parse HEAD) +UMAMI_KUBE_NAMESPACE?=umami ##@ Development - Helper commands for development .PHONY: md-lint md-lint: ## Lint markdown files @@ -113,7 +114,10 @@ check-kubectl: .PHONY: load-images load-images: ## Load images onto Kind cluster + $(CMD_PREFIX) docker pull ghcr.io/instructlab/ui/ui:main + $(CMD_PREFIX) docker pull registry.redhat.io/rhel9/postgresql-15:9.5-1733127512 $(CMD_PREFIX) kind load --name $(ILAB_KUBE_CLUSTER_NAME) docker-image ghcr.io/instructlab/ui/ui:main + $(CMD_PREFIX) kind load --name $(ILAB_KUBE_CLUSTER_NAME) docker-image registry.redhat.io/rhel9/postgresql-15:9.5-1733127512 .PHONY: stop-dev-kind stop-dev-kind: check-kind ## Stop the Kind cluster to destroy the development environment @@ -140,10 +144,16 @@ deploy: wait-for-readiness ## Deploy a InstructLab UI development stack onto a k $(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) apply -k ./deploy/k8s/overlays/kind $(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) wait --for=condition=Ready pods -n $(ILAB_KUBE_NAMESPACE) --all -l app.kubernetes.io/part-of=ui --timeout=15m + $(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) apply -k ./deploy/k8s/overlays/kind/umami + $(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) wait --for=condition=Ready pods -n $(UMAMI_KUBE_NAMESPACE) --all -l app.kubernetes.io/part-of=umami --timeout=15m + $(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) port-forward -n $(UMAMI_KUBE_NAMESPACE) service/umami 3001:3001 + + .PHONY: redeploy redeploy: ui-image load-images ## Redeploy the InstructLab UI stack onto a kubernetes cluster $(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) -n $(ILAB_KUBE_NAMESPACE) rollout restart deploy/ui $(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) -n $(ILAB_KUBE_NAMESPACE) rollout restart deploy/pathservice + $(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) -n $(UMAMI_KUBE_NAMESPACE) rollout restart deploy/umami .PHONY: undeploy undeploy: ## Undeploy the InstructLab UI stack from a kubernetes cluster @@ -151,9 +161,10 @@ undeploy: ## Undeploy the InstructLab UI stack from a kubernetes cluster rm ./deploy/k8s/overlays/kind/.env ; \ fi $(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) delete namespace $(ILAB_KUBE_NAMESPACE) + $(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) delete namespace $(UMAMI_KUBE_NAMESPACE) .PHONY: start-dev-kind ## Run the development environment on Kind cluster -start-dev-kind: setup-kind deploy ## Setup a Kind cluster and deploy InstructLab UI on it +start-dev-kind: setup-kind load-images deploy ## Setup a Kind cluster and deploy InstructLab UI on it ##@ OpenShift - UI prod and qa deployment on OpenShift .PHONY: deploy-qa-openshift diff --git a/deploy/k8s/base/umami/deployment.yaml b/deploy/k8s/base/umami/deployment.yaml index 8d7ee15f..14f73d3c 100644 --- a/deploy/k8s/base/umami/deployment.yaml +++ b/deploy/k8s/base/umami/deployment.yaml @@ -2,17 +2,11 @@ apiVersion: apps/v1 kind: Deployment metadata: name: umami - labels: - app: umami spec: replicas: 1 - selector: - matchLabels: - app: umami + strategy: + type: RollingUpdate template: - metadata: - labels: - app: umami spec: containers: - name: postgresql @@ -73,6 +67,7 @@ spec: value: "3001" ports: - containerPort: 3001 + restartPolicy: Always volumes: - name: db-data persistentVolumeClaim: diff --git a/deploy/k8s/base/umami/kustomization.yaml b/deploy/k8s/base/umami/kustomization.yaml index 89967049..afa29a2e 100644 --- a/deploy/k8s/base/umami/kustomization.yaml +++ b/deploy/k8s/base/umami/kustomization.yaml @@ -7,3 +7,11 @@ resources: - postgresql-pvc.yaml - postgresql-service.yaml - umami-service.yaml +labels: + - includeSelectors: true + pairs: + app: umami + app.kubernetes.io/component: umami + app.kubernetes.io/instance: umami + app.kubernetes.io/name: umami + app.kubernetes.io/part-of: umami diff --git a/deploy/k8s/base/umami/namespace.yaml b/deploy/k8s/base/umami/namespace.yaml index 170ed2db..196046b9 100644 --- a/deploy/k8s/base/umami/namespace.yaml +++ b/deploy/k8s/base/umami/namespace.yaml @@ -2,5 +2,3 @@ apiVersion: v1 kind: Namespace metadata: name: umami - labels: - name: umami diff --git a/deploy/k8s/base/umami/postgresql-pvc.yaml b/deploy/k8s/base/umami/postgresql-pvc.yaml index 3ffa7397..3eaa5a4a 100644 --- a/deploy/k8s/base/umami/postgresql-pvc.yaml +++ b/deploy/k8s/base/umami/postgresql-pvc.yaml @@ -2,8 +2,6 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: umami-postgresql-db-data - labels: - app: umami spec: accessModes: - ReadWriteOnce diff --git a/deploy/k8s/base/umami/postgresql-service.yaml b/deploy/k8s/base/umami/postgresql-service.yaml index 6cd17d10..e4e88fb0 100644 --- a/deploy/k8s/base/umami/postgresql-service.yaml +++ b/deploy/k8s/base/umami/postgresql-service.yaml @@ -3,7 +3,6 @@ kind: Service metadata: name: umami-db labels: - app: umami component: db spec: ports: diff --git a/deploy/k8s/base/umami/umami-service.yaml b/deploy/k8s/base/umami/umami-service.yaml index f7268d15..47078319 100644 --- a/deploy/k8s/base/umami/umami-service.yaml +++ b/deploy/k8s/base/umami/umami-service.yaml @@ -4,7 +4,6 @@ kind: Service metadata: name: umami labels: - app: umami component: web spec: ports: diff --git a/deploy/k8s/overlays/kind/README.md b/deploy/k8s/overlays/kind/README.md index c222aff7..baddfb3f 100644 --- a/deploy/k8s/overlays/kind/README.md +++ b/deploy/k8s/overlays/kind/README.md @@ -1,19 +1,23 @@ -# Introduction +# Kind deployment Kind is a tool that can allow you to emulate a local kuberenetes cluster. These manifests will help you provision a correctly configured kind cluster and apply the resources. -# Usage +## Usage -## Building the cluster +The easiest way is to use the predefined `make` targets at the root of the repo, such as `make start-dev-kind`. However this document will also explain the process of +deploying from the manifests themselves. + +### Building the cluster You can either create a default cluster, or use the setup we have to mimic our openshift dpeloyment more closely: `kind create cluster --config kind.yaml`. -## Applying the kind-ingress manifests +### Applying the kind-ingress manifests If you dont care about using an ingress and choose to hit the services directly, use host networking on your container runtime on which you are using kind, or some other -edge case which would remove the necesity of ingresses, you can simple ignore the [kind-ingress.yaml](./kind-ingress.yaml). However if you do want to use ingresses +edge case which would remove the necesity of ingresses, you can simple ignore the [kind-ingress.yaml](./kind-ingress.yaml). However if you do want to use ingresses (which are a part of both the default UI stack and the umami metrics stack), then you should deploy the kind ingress: `kubectl create -f kind-ingress.yaml`. This will take some time to deploy, so now we can simply wait for it: + ```bash kubectl wait --namespace ingress-nginx \ --for=condition=ready pod \ diff --git a/deploy/k8s/overlays/kind/umami/README.md b/deploy/k8s/overlays/kind/umami/README.md index dc831a8a..30cc66cb 100644 --- a/deploy/k8s/overlays/kind/umami/README.md +++ b/deploy/k8s/overlays/kind/umami/README.md @@ -1,10 +1,11 @@ # Notes To try to deploy Umami via kind you must first create and apply the manifests 1 directory up. After that, creating umami within kind is very straightforward. -Simply set your `.umami-secret.env` with your values from the template `example.umami-secret.env` in this directory. After this, we need to import the +Simply set your `.umami-secret.env` with your values from the template `example.umami-secret.env` in this directory. After this, we need to import the container image that we use for the Umami postgresql database. -To do this, we first start by pulling down the image +To do this, we first start by pulling down the image: + ```bash PSQL_IMAGE="registry.redhat.io/rhel9/postgresql-15:9.5-1733127512" docker pull ${PSQL_IMAGE} @@ -14,4 +15,4 @@ If you provisioned a default kind cluster, you can load your image onto it as fo However if you provisioned a kind cluster with the [kind.yaml](../kind.yaml) configuration we provided in the directory above this, then you will need to specify the name of the cluster as well: `kind load docker-image ${PSQL_IMAGE} --name instructlab-ui` -After that you can apply the Umami manifests: `kustomize build . | kubectl apply -f -`. +After that you can apply the Umami manifests: `kustomize build . | kubectl apply -f -`.