Skip to content

Commit

Permalink
kind makefile changes, better labels in base manifests, md linting
Browse files Browse the repository at this point in the history
Signed-off-by: greg pereira <grpereir@redhat.com>
  • Loading branch information
Gregory-Pereira committed Dec 6, 2024
1 parent 895e3eb commit 1ffe86e
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 23 deletions.
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -140,20 +144,27 @@ 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
$(CMD_PREFIX) if [ -f ./deploy/k8s/overlays/kind/.env ]; then \
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
Expand Down
11 changes: 3 additions & 8 deletions deploy/k8s/base/umami/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,6 +67,7 @@ spec:
value: "3001"
ports:
- containerPort: 3001
restartPolicy: Always
volumes:
- name: db-data
persistentVolumeClaim:
Expand Down
8 changes: 8 additions & 0 deletions deploy/k8s/base/umami/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions deploy/k8s/base/umami/namespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ apiVersion: v1
kind: Namespace
metadata:
name: umami
labels:
name: umami
2 changes: 0 additions & 2 deletions deploy/k8s/base/umami/postgresql-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: umami-postgresql-db-data
labels:
app: umami
spec:
accessModes:
- ReadWriteOnce
Expand Down
1 change: 0 additions & 1 deletion deploy/k8s/base/umami/postgresql-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ kind: Service
metadata:
name: umami-db
labels:
app: umami
component: db
spec:
ports:
Expand Down
1 change: 0 additions & 1 deletion deploy/k8s/base/umami/umami-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ kind: Service
metadata:
name: umami
labels:
app: umami
component: web
spec:
ports:
Expand Down
14 changes: 9 additions & 5 deletions deploy/k8s/overlays/kind/README.md
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
7 changes: 4 additions & 3 deletions deploy/k8s/overlays/kind/umami/README.md
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -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 -`.

0 comments on commit 1ffe86e

Please sign in to comment.