Skip to content

Commit b11205d

Browse files
committedJul 10, 2024
Add manifests for local kind development and openshift
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
1 parent c7b1641 commit b11205d

20 files changed

+1129
-140
lines changed
 

‎.dockerignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.env
2+
.env.example
3+
.next
4+
auth.log
5+
.yamllint.yaml
6+
SECURITY.md
7+
README.md
8+
Makefile
9+
MAINTAINERS.md
10+
LICENSE
11+
CONTRIBUTING.md
12+
CODE_OF_CONDUCT.md
13+
.markdownlint-cli2.json
14+
deploy/
15+
docs/
16+
certificates/
17+
server/
18+
.github/

‎.env.example

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ IL_UI_ADMIN_USERNAME=admin
22
IL_UI_ADMIN_PASSWORD=password
33
OAUTH_GITHUB_ID=<OAUTH_APP_ID>
44
OAUTH_GITHUB_SECRET=<OAUTH_APP_SECRET>
5+
GITHUB_TOKEN=<TOKEN FOR OAUTH INSTRUCTLAB MEMBER LOOKUP>
56
NEXTAUTH_SECRET=your_super_secret_random_string
67
NEXTAUTH_URL=http://localhost:3000
8+
9+
TAXONOMY_DOCUMENTS_REPO=github.com/<USER_ID>/<REPO_NAME>
10+
NEXT_PUBLIC_TAXONOMY_REPO_OWNER=<GITHUB_ACCOUNT>
11+
NEXT_PUBLIC_TAXONOMY_REPO=<REPO_NAME>
12+
713
IL_GRANITE_API=<GRANITE_HOST>
814
IL_GRANITE_MODEL_NAME=<GRANITE_MODEL_NAME>
915
IL_MERLINITE_API=<MERLINITE_HOST>
1016
IL_MERLINITE_MODEL_NAME=<MERLINITE_MODEL_NAME>
11-
GITHUB_TOKEN=<TOKEN FOR OAUTH INSTRUCTLAB MEMBER LOOKUP>
12-
TAXONOMY_DOCUMENTS_REPO=github.com/<USER_ID>/<REPO_NAME>
13-
NEXT_PUBLIC_TAXONOMY_REPO_OWNER=<GITHUB_ACCOUNT>
14-
NEXT_PUBLIC_TAXONOMY_REPO=<REPO_NAME>

‎Containerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM node:22-alpine
33
WORKDIR /app
44

55
COPY package*.json ./
6-
RUN npm install
6+
RUN npm install --production
77
COPY ./ .
88

99
RUN npm run build

‎Makefile

+93-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ else
1616
PIPE_DEV_NULL=
1717
endif
1818

19+
ILAB_KUBE_CONTEXT?=kind-instructlab-ui
20+
ILAB_KUBE_NAMESPACE?=instructlab
21+
ILAB_KUBE_CLUSTER_NAME?=instructlab-ui
22+
TAG=$(shell git rev-parse HEAD)
23+
##@ Development - Helper commands for development
1924
.PHONY: md-lint
2025
md-lint: ## Lint markdown files
2126
$(ECHO_PREFIX) printf " %-12s ./...\n" "[MD LINT]"
22-
$(CMD_PREFIX) podman run --rm -v $(CURDIR):/workdir docker.io/davidanson/markdownlint-cli2:v0.6.0 > /dev/null
27+
$(CMD_PREFIX) docker run --rm -v $(CURDIR):/workdir docker.io/davidanson/markdownlint-cli2:v0.6.0 > /dev/null
2328

2429
.PHONY: action-lint
2530
action-lint: ## Lint GitHub Action workflows
@@ -31,6 +36,91 @@ action-lint: ## Lint GitHub Action workflows
3136
fi
3237
$(CMD_PREFIX) actionlint -color
3338

39+
##@ Artifacts - Command to build and publish artifacts
3440
ui-image: Containerfile ## Build continaer image for the InstructLab UI
35-
$(ECHO_PREFIX) printf " %-12s Containerfile\n" "[PODMAN]"
36-
$(CMD_PREFIX) podman build -f Containerfile -t ghcr.io/instructlab/ui/ui:main .
41+
$(ECHO_PREFIX) printf " %-12s Containerfile\n" "[docker]"
42+
$(CMD_PREFIX) docker build -f Containerfile -t ghcr.io/instructlab/ui/ui:$(TAG) .
43+
$(CMD_PREFIX) docker tag ghcr.io/instructlab/ui/ui:$(TAG) ghcr.io/instructlab/ui/ui:main
44+
45+
46+
##@ Kubernetes - kind dev environment
47+
.PHONY: check-kind
48+
check-kind:
49+
$(CMD_PREFIX) if [ -z "$(shell which kind)" ]; then \
50+
echo "Please install kind and then start the kind dev environment." ; \
51+
echo "https://kind.sigs.k8s.io/" ; \
52+
exit 1 ; \
53+
fi
54+
55+
.PHONY: check-kubectl
56+
check-kubectl:
57+
$(CMD_PREFIX) if [ -z "$(shell which kubectl)" ]; then \
58+
echo "Please install kubectl" ; \
59+
echo "https://kubernetes.io/docs/tasks/tools/#kubectl" ; \
60+
exit 1 ; \
61+
fi
62+
63+
.PHONY: load-images
64+
load-images: ## Load images onto kind
65+
$(CMD_PREFIX) kind load --name $(ILAB_KUBE_CLUSTER_NAME) docker-image ghcr.io/instructlab/ui/ui:main
66+
67+
.PHONY: stop-dev
68+
stop-dev: check-kind ## Stop the kind cluster to destroy the development environment
69+
$(CMD_PREFIX) kind delete cluster --name $(ILAB_KUBE_CLUSTER_NAME)
70+
71+
.PHONY: setup-kind
72+
setup-kind: check-kind check-kubectl stop-dev ## Create a kind cluster with ingress enabled
73+
$(CMD_PREFIX) kind create cluster --config ./deploy/k8s/kind.yaml
74+
$(CMD_PREFIX) kubectl cluster-info
75+
$(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) apply -f ./deploy/k8s/kind-ingress.yaml
76+
77+
.PHONY: wait-for-readiness
78+
wait-for-readiness: # Wait for operators to be ready
79+
$(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) -n ingress-nginx rollout restart deployment ingress-nginx-controller
80+
$(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) -n ingress-nginx rollout status deployment ingress-nginx-controller --timeout=5m
81+
82+
.PHONY: deploy
83+
deploy: wait-for-readiness ## Deploy a InstructLab UI development stack onto a kubernetes cluster
84+
$(CMD_PREFIX) if [ ! -f .env ]; then \
85+
echo "Please create a .env file in the root of the project." ; \
86+
exit 1 ; \
87+
fi
88+
$(CMD_PREFIX) yes | cp -rf .env ./deploy/k8s/overlays/kind/.env
89+
$(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) apply -k ./deploy/k8s/overlays/kind
90+
$(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
91+
92+
.PHONY: redeploy
93+
redeploy: ui-image load-images ## Redeploy the InstructLab UI stack onto a kubernetes cluster
94+
$(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) -n $(ILAB_KUBE_NAMESPACE) rollout restart deploy/ui
95+
96+
.PHONY: undeploy
97+
undeploy: ## Undeploy the InstructLab UI stack from a kubernetes cluster
98+
$(CMD_PREFIX) if [ -f ./deploy/k8s/overlays/kind/.env ]; then \
99+
rm ./deploy/k8s/overlays/kind/.env ; \
100+
fi
101+
$(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) delete namespace $(ILAB_KUBE_NAMESPACE)
102+
103+
.PHONY: start-dev ## Run the development environment on kind
104+
start-dev: setup-kind deploy ## Setup a kind cluster and deploy InstructLab UI on it
105+
106+
##@ OpenShift - UI deployment in OpenShift
107+
.PHONY: deploy-openshift
108+
deploy-openshift: ## Deploy the InstructLab UI on OpenShift
109+
$(CMD_PREFIX) if [ ! -f .env ]; then \
110+
echo "Please create a .env file in the root of the project." ; \
111+
exit 1 ; \
112+
fi
113+
114+
$(CMD_PREFIX) yes | cp -rf .env ./deploy/k8s/overlays/openshift/.env
115+
$(CMD_PREFIX) oc apply -k ./deploy/k8s/overlays/openshift
116+
$(CMD_PREFIX) oc wait --for=condition=Ready pods -n $(ILAB_KUBE_NAMESPACE) --all -l app.kubernetes.io/part-of=ui --timeout=15m
117+
118+
.PHONY: redeploy-openshift
119+
redeploy-openshift: deploy-openshift ## Redeploy the InstructLab UI on OpenShift
120+
121+
.PHONY: undeploy-openshift
122+
undeploy-openshift: ## Undeploy the InstructLab UI on OpenShift
123+
$(CMD_PREFIX) oc delete -k ./deploy/k8s/overlays/openshift
124+
$(CMD_PREFIX) if [ -f ./deploy/k8s/overlays/openshift/.env ]; then \
125+
rm ./deploy/k8s/overlays/openshift/.env ; \
126+
fi

‎deploy/k8s/base/kustomization.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: instructlab
4+
resources:
5+
- namespace.yaml
6+
- ui
7+
labels:
8+
- includeSelectors: true
9+
pairs:
10+
app.kubernetes.io/part-of: ui

‎deploy/k8s/base/namespace.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: instructlab

‎deploy/k8s/base/ui/deployment.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: ui
5+
spec:
6+
replicas: 1
7+
strategy:
8+
type: RollingUpdate
9+
template:
10+
spec:
11+
containers:
12+
- name: ui
13+
image: ghcr.io/instructlab/ui/ui:main
14+
imagePullPolicy: Always
15+
resources:
16+
requests:
17+
cpu: 100m
18+
memory: 200Mi
19+
limits:
20+
cpu: 100m
21+
memory: 200Mi
22+
ports:
23+
- name: http
24+
protocol: TCP
25+
containerPort: 3000
26+
envFrom:
27+
- secretRef:
28+
name: ui-config
29+
restartPolicy: Always

‎deploy/k8s/base/ui/ingress-ui.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: ui
5+
spec:
6+
tls:
7+
- hosts:
8+
- localhost
9+
secretName: letsencrypt-ui
10+
rules:
11+
- host: localhost
12+
http:
13+
paths:
14+
- pathType: Prefix
15+
path: "/"
16+
backend:
17+
service:
18+
name: ui
19+
port:
20+
number: 8080

‎deploy/k8s/base/ui/kustomization.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- deployment.yaml
5+
- service.yaml
6+
- ingress-ui.yaml
7+
labels:
8+
- includeSelectors: true
9+
pairs:
10+
app.kubernetes.io/component: ui
11+
app.kubernetes.io/instance: ui
12+
app.kubernetes.io/name: ui

‎deploy/k8s/base/ui/service.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: ui
5+
spec:
6+
clusterIP: None
7+
selector:
8+
app.kubernetes.io/component: ui
9+
app.kubernetes.io/instance: ui
10+
app.kubernetes.io/name: ui
11+
ports:
12+
- port: 8080
13+
targetPort: 3000

0 commit comments

Comments
 (0)