Skip to content

NT548-P11-DevOps-Technology/assignment-lab02-kubernetes-manifests

 
 

Repository files navigation

Kubernetes Configuration with Jenkins Pipeline

🛈 Overview

This repo contains Kubernetes configuration files used for deploying the application to staging and production environments. The configuration is organized into modules for each service, including both front-end and back-end services.

🧰 Components

  • Manifests:

    • deployment.yaml: Defines the deployment configurations for the service.
    • service.yaml: Specifies the service configuration for exposing the deployment.
    • secret.yaml: Contains sensitive data which should be stored as base64 type.
    • configMap.yaml: Stores non-confidential data in key-value pairs.
    • ingress.yaml: Configures ingress rules for external access to the services.
    • persistentVolume.yaml: Defines persistent storage volumes.
    • kustomization.yaml: Create variations of K8s resources and configurations for specific use cases.
  • Staging Environment

    • A K8s cluster set up for staging environment using Terraform & Ansible with kubeadm tool. I already have a repo that sets up the cluster like the architecture below 👉 Here

Stag Environment

  • Production Environment

Prod Environment

🚀 Getting Started

Prerequisites

  • Kubernetes clusters: Ensure you have a K8s clusters set up for staging and production environments.
  • kubectl: Install and configure kubectl to interact with your K8s cluster.
    → you need to configure the config file in .kube folder after installing kubectl tool. Follow the instructions here.
  • Jenkins: Set up Jenkins for CI/CD pipelines to deploy the application to K8s clusters.
  • SonarQube: Configure SonarQube for code quality analysis in the CI/CD pipeline.
  • Trivy: Integrate Trivy for scanning Docker images for vulnerabilities.

Setup manual

  1. Clone the repository:
git clone https://github.com/NT114-O21-DACN-DevOps/class-management-k8s-config.git
cd class-management-k8s-config
  1. Apply the manifests
  • Because of using kustomization file, you only need to apply all of the config files with 1 command:
kubectl apply -k .

Setup with Jenkins Pipeline

  1. Prepare Jenkins Pipeline
  • Add the necessary credentials for accessing the K8s clusters, GitHub repository, SonarQube, and other services.

Prod Environment

- Add SonarQube server in Jenkins configuration.

Prod Environment

- Add SonarQube scanner in Jenkins configuration.

Prod Environment

  1. Create a new pipeline in Jenkins
  • Create a new pipeline and configure the pipeline script to deploy the application to the K8s clusters.
  • You can use the Jenkinsfile in this repository as a reference for the pipeline script.

Jenkins Pipeline

  1. Run the Jenkins Pipeline
  • Run the Jenkins pipeline to deploy the application to the staging and production environments.

Jenkins Pipeline

Notes

  • Ensure that the configMap.yaml and secret.yaml files contain appropriate configurations and sensitive data for each environment.
  • Update ingress.yaml with the correct rules for routing external traffic to your services.
  • Review the persistentVolume.yaml to configure persistent storage as required by your application.

About

Kubernetes Configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors