Skip to content

Repository files navigation

Final Project Kubernetes

Overview

Kubernetes infrastructure for the hotel reservation final project.

This repo deploys:

  • Frontend & Backend
  • MySQL
  • Adminer
  • Nexus registry
  • Jenkins with Kubernetes agents
  • Argo CD applications
  • OpenBao
  • Elasticsearch, Kibana, Logstash, Beats, kube-state-metrics, and APM

Project architecture

Project architecture

Related repositories

Requirements

  • Docker or Podman
  • Kind
  • kubectl
  • GitHub credentials for Jenkins and Argo CD

Secret configuration

OpenBao is the only source of project secrets. Copy its example seed file before bootstrapping the cluster:

cp openbao/secrets.example.json openbao/secrets.json

Fill in every value in openbao/secrets.json. Do not commit the real file. OpenBao stores the values at secret/final-project and provides the Kubernetes Secrets required by the workloads.

Local URLs

Frontend:        http://localhost:80
Backend API:     http://localhost:5000
Kibana:          https://localhost:5601
APM server:      http://localhost:8200
Nexus UI:        http://localhost:8081
Nexus registry:  localhost:5001
Adminer:         http://localhost:8082
Jenkins:         http://localhost:8083
Argo CD:         http://localhost:8084

Local deployment

1. Create the Kind cluster

kind create cluster --config kind-config.yaml
kubectl config use-context kind-final-project

2. Bootstrap the cluster

This creates shared namespaces, installs the Elastic operator, MySQL operator, OpenBao operator, and Argo CD.

kubectl apply --server-side --force-conflicts -k .

3. Seed OpenBao

kubectl wait --for=condition=complete \
  job/final-project-openbao-init-secrets \
  -n openbao \
  --timeout=5m
kubectl delete secret final-project-openbao-seed -n openbao

4. Deploy Argo CD apps

kubectl apply -k argocd/apps

Get the Argo CD admin password:

kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo

Username: admin

Useful operations

Configure Nexus

Get the Nexus admin password:

kubectl -n nexus exec deploy/nexus -c nexus -- cat /nexus-data/admin.password

Username: admin

Create a Docker hosted repository:

Recipe: docker (hosted)
Name: docker-hosted
HTTP: 5001

Create a Nexus role:

Type: Nexus role
Role ID: nx-docker
Role Name: nx-docker
Modify Applied Privileges: nx-repository-view-docker-docker-hosted-*

Create a local Nexus user for image pulls:

ID(username): k8s
Password: "****"
Status: Active
Role Granted: nx-docker

Enable the Docker Bearer Token Realm:

Active:
  - Local Authenticating Realm
  - Docker Bearer Token Realm

Set the same Nexus username and password in openbao/secrets.json. The OpenBao initialization job creates the image pull credentials for the backend and frontend namespaces.

Login locally:

docker login localhost:5001

For local testing, add the insecure registry to Docker daemon.json:

{
  "insecure-registries": ["localhost:5001"]
}

Configure Jenkins

Jenkins uses JENKINS_ADMIN_ID and JENKINS_ADMIN_PASSWORD synchronized from OpenBao.

Add this webhook to the backend and frontend repositories:

http://<jenkins-url>/generic-webhook-trigger/invoke?token=build

GitHub cannot reach localhost:8083, so expose Jenkins with a tunnel or public URL. The trigger runs only for pushes to dev.

Configure Kibana

Get the Elasticsearch password:

kubectl get secret elasticsearch-es-elastic-user \
  -n elastic-system \
  -o go-template='{{.data.elastic | base64decode}}'

Username: elastic

Run this in Kibana Dev Tools to fix index status in the local single-node cluster:

PUT /*/_settings?expand_wildcards=all
{
  "index": {
    "number_of_replicas": 0
  }
}

Create these data views in Kibana:

Name: filebeat
Index pattern: filebeat-*
Timestamp field: @timestamp
Name: metricbeat
Index pattern: metricbeat-*
Timestamp field: @timestamp

Docker images

The Backend API and Frontend manifests expect images in the local Nexus registry:

localhost:5001/final-project-backend:<tag>
localhost:5001/final-project-frontend:<tag>

Build and push these images from the Backend and Frontend repositories after Nexus is configured.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors