Skip to content

Commit

Permalink
Merge pull request #207 from vishnoianil/deploy-prod
Browse files Browse the repository at this point in the history
Prepare for production beta release of InstructLab Ui
  • Loading branch information
nerdalert authored Sep 26, 2024
2 parents 2d3861c + c6f6332 commit 12fd2c2
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 29 deletions.
65 changes: 51 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ action-lint: ## Lint GitHub Action workflows
fi
$(CMD_PREFIX) actionlint -color

.PHONY: yaml-lint
yaml-lint: ## Lint yaml files
$(CMD_PREFIX) if ! which yamllint >/dev/null 2>&1; then \
echo "Please install yamllint." ; \
echo "See: https://yamllint.readthedocs.io/en/stable/quickstart.html" ; \
exit 1 ; \
fi
$(ECHO_PREFIX) printf " %-12s ./...\n" "[YAML LINT]"
$(CMD_PREFIX) yamllint -c .yamllint.yaml deploy --strict

##@ Artifacts - Command to build and publish artifacts
ui-image: Containerfile ## Build continaer image for the InstructLab UI
$(ECHO_PREFIX) printf " %-12s Containerfile\n" "[docker]"
Expand Down Expand Up @@ -89,9 +99,9 @@ stop-dev-kind: check-kind ## Stop the Kind cluster to destroy the development en

.PHONY: setup-kind
setup-kind: check-kind check-kubectl stop-dev ## Create a Kind cluster with ingress enabled
$(CMD_PREFIX) kind create cluster --config ./deploy/k8s/kind.yaml
$(CMD_PREFIX) kind create cluster --config ./deploy/k8s/overlays/kind/kind.yaml
$(CMD_PREFIX) kubectl cluster-info
$(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) apply -f ./deploy/k8s/kind-ingress.yaml
$(CMD_PREFIX) kubectl --context=$(ILAB_KUBE_CONTEXT) apply -f ./deploy/k8s/overlays/kind/kind-ingress.yaml

.PHONY: wait-for-readiness
wait-for-readiness: # Wait for operators to be ready
Expand Down Expand Up @@ -123,24 +133,51 @@ undeploy: ## Undeploy the InstructLab UI stack from a kubernetes cluster
.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

##@ OpenShift - UI deployment in OpenShift
.PHONY: deploy-openshift
deploy-openshift: ## Deploy the InstructLab UI on OpenShift
##@ OpenShift - UI prod and qa deployment on OpenShift
.PHONY: deploy-qa-openshift
deploy-qa-openshift: ## Deploy QA stack of the InstructLab UI on OpenShift
$(CMD_PREFIX) if [ ! -f .env ]; then \
echo "Please create a .env file in the root of the project." ; \
exit 1 ; \
fi

$(CMD_PREFIX) yes | cp -rf .env ./deploy/k8s/overlays/openshift/.env
$(CMD_PREFIX) oc apply -k ./deploy/k8s/overlays/openshift
$(CMD_PREFIX) yes | cp -rf .env ./deploy/k8s/overlays/openshift/qa/.env
$(CMD_PREFIX) oc apply -k ./deploy/k8s/overlays/openshift/qa
$(CMD_PREFIX) oc wait --for=condition=Ready pods -n $(ILAB_KUBE_NAMESPACE) --all -l app.kubernetes.io/part-of=ui --timeout=15m

.PHONY: redeploy-openshift
redeploy-openshift: deploy-openshift ## Redeploy the InstructLab UI on OpenShift
.PHONY: redeploy-qa-openshift
redeploy-qa-openshift: ## Redeploy QA stack of the InstructLab UI on OpenShift
$(CMD_PREFIX) oc -n $(ILAB_KUBE_NAMESPACE) rollout restart deploy/ui
$(CMD_PREFIX) oc -n $(ILAB_KUBE_NAMESPACE) rollout restart deploy/pathservice


.PHONY: undeploy-qa-openshift
undeploy-qa-openshift: ## Undeploy QA stack of the InstructLab UI on OpenShift
$(CMD_PREFIX) oc delete -k ./deploy/k8s/overlays/openshift/qa
$(CMD_PREFIX) if [ -f ./deploy/k8s/overlays/openshift/qa/.env ]; then \
rm ./deploy/k8s/overlays/openshift/qa/.env ; \
fi

.PHONY: deploy-prod-openshift
deploy-prod-openshift: ## Deploy production stack of the InstructLab UI on OpenShift
$(CMD_PREFIX) if [ ! -f .env ]; then \
echo "Please create a .env file in the root of the project." ; \
exit 1 ; \
fi

$(CMD_PREFIX) yes | cp -rf .env ./deploy/k8s/overlays/openshift/prod/.env
$(CMD_PREFIX) oc apply -k ./deploy/k8s/overlays/openshift/prod
$(CMD_PREFIX) oc wait --for=condition=Ready pods -n $(ILAB_KUBE_NAMESPACE) --all -l app.kubernetes.io/part-of=ui --timeout=15m

.PHONY: redeploy-prod-openshift
redeploy-prod-openshift: ## Redeploy production stack of the InstructLab UI on OpenShift
$(CMD_PREFIX) oc -n $(ILAB_KUBE_NAMESPACE) rollout restart deploy/ui
$(CMD_PREFIX) oc -n $(ILAB_KUBE_NAMESPACE) rollout restart deploy/pathservice


.PHONY: undeploy-openshift
undeploy-openshift: ## Undeploy the InstructLab UI on OpenShift
$(CMD_PREFIX) oc delete -k ./deploy/k8s/overlays/openshift
$(CMD_PREFIX) if [ -f ./deploy/k8s/overlays/openshift/.env ]; then \
rm ./deploy/k8s/overlays/openshift/.env ; \
.PHONY: undeploy-prod-openshift
undeploy-prod-openshift: ## Undeploy production stack of the InstructLab UI on OpenShift
$(CMD_PREFIX) oc delete -k ./deploy/k8s/overlays/openshift/prod
$(CMD_PREFIX) if [ -f ./deploy/k8s/overlays/openshift/prod/.env ]; then \
rm ./deploy/k8s/overlays/openshift/prod/.env ; \
fi
6 changes: 3 additions & 3 deletions deploy/k8s/base/ui/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ metadata:
name: ui
spec:
tls:
- hosts:
- localhost
secretName: letsencrypt-ui
- hosts:
- localhost
secretName: letsencrypt-ui
rules:
- host: localhost
http:
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions deploy/k8s/overlays/kind/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ resources:
- ../../base

secretGenerator:
- name: ui-config
envs:
- .env
- name: ui-config
envs:
- .env

patches:
- target:
Expand Down Expand Up @@ -40,4 +40,3 @@ patches:
- op: replace
path: /spec/template/spec/containers/0/imagePullPolicy
value: Always
23 changes: 23 additions & 0 deletions deploy/k8s/overlays/openshift/prod/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: letsencrypt-ui
spec:
secretName: letsencrypt-ui
duration: 2160h0m0s
renewBefore: 360h0m0s
subject:
organizations:
- InstructLab
privateKey:
algorithm: RSA
encoding: PKCS1
size: 2048
usages:
- server auth
- client auth
dnsNames:
- ui.instructlab.ai
issuerRef:
name: letsencrypt-ui
kind: Issuer
File renamed without changes.
48 changes: 48 additions & 0 deletions deploy/k8s/overlays/openshift/prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: instructlab
resources:
- ../../../base
- issuer.yaml
- certificate.yaml

secretGenerator:
- name: ui-config
envs:
- .env

patches:
- target:
kind: Ingress
name: ui
patch: |-
- op: replace
path: /spec/rules/0/http/paths/0/pathType
value: ImplementationSpecific
- op: replace
path: /spec/rules/0/http/paths/0/path
value: ''
- op: replace
path: /spec/rules/0/host
value: ui.instructlab.ai
- op: replace
path: /spec/tls/0/hosts/0
value: ui.instructlab.ai
# Override the UI image for Openshift production deployment
- target:
kind: Deployment
name: ui
patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: quay.io/instructlab-ui/ui:v1.0.0-beta # Override this image if you want to use a different UI image
# Override the pathservice image for Openshift production deployment
- target:
kind: Deployment
name: pathservice
patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: quay.io/instructlab-ui/pathservice:v1.0.0-beta # Override this image if you want to use a different pathservice image
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
renewBefore: 360h0m0s
subject:
organizations:
- nexodus
- InstructLab
privateKey:
algorithm: RSA
encoding: PKCS1
Expand Down
14 changes: 14 additions & 0 deletions deploy/k8s/overlays/openshift/qa/issuer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: letsencrypt-ui
spec:
acme:
email: avishnoi@redhat.com
privateKeySecretRef:
name: letsencrypt-ui-key
server: 'https://acme-v02.api.letsencrypt.org/directory'
solvers:
- http01:
ingress:
serviceType: ClusterIP
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: instructlab
resources:
- ../../base
- ../../../base
- issuer.yaml
- certificate.yaml

secretGenerator:
- name: ui-config
envs:
- .env
- name: ui-config
envs:
- .env

patches:
- target:
Expand All @@ -29,7 +29,7 @@ patches:
path: /spec/tls/0/hosts/0
value: qa.ui.instructlab.ai
# Override the UI image for Openshift deployment
# Override the UI image for Openshift QA deployment
- target:
kind: Deployment
name: ui
Expand All @@ -38,12 +38,11 @@ patches:
path: /spec/template/spec/containers/0/image
value: quay.io/instructlab-ui/ui:main # Override this image if you want to use a different UI image
# Override the pathservice image for Openshift deployment
# Override the pathservice image for Openshift QA deployment
- target:
kind: Deployment
name: pathservice
patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: quay.io/instructlab-ui/pathservice:main # Override this image if you want to use a different pathservice image

0 comments on commit 12fd2c2

Please sign in to comment.