Giter Club home page Giter Club logo

gcp-devops's Introduction

GKE Cluster using Terraform and Jenkins

This repository contains the Terraform code to build GKE (Google Kubernetes Engine) and Kubernetes components to create services and deployment that configure jenkins for CI/CD which can build and run containers and service loadbalancer.

Requirements

System

  • GNU/Linux
  • terraform
  • docker
  • kubernetes

Get the Code

https://github.com/mustafaabdelbadea/GCP-DevOps
cd GCP-DevOps

Structure

GCP-DevOps
├── configure_pod.sh
├── images
│   └── Trello.png
├── kubernetes
│   ├── 1_namespace.yml
│   ├── 2_roles.yml
│   ├── 3_jenkins-service-account.yml
│   ├── 4_role-binding.yml
│   ├── 5_jenkins-service.yml
│   ├── 6_jenkins-deploy.yml
│   └── apply.sh
├── README.md
└── terraform
    ├── apis
    │   ├── main.tf
    │   ├── outputs.tf
    │   └── varibales.tf
    ├── apis.tf
    ├── cluster
    │   ├── cluster.tf
    │   ├── node-pool.tf
    │   ├── outputs.tf
    │   ├── service-account.tf
    │   └── variables.tf
    ├── cluster.tf
    ├── network
    │   ├── firewall.tf
    │   ├── nat.tf
    │   ├── outputs.tf
    │   ├── router.tf
    │   ├── subnets.tf
    │   ├── variables.tf
    │   └── vpc.tf
    ├── network..tf
    ├── prod.tfvars
    ├── provider.tf
    └── variables.tf

⏫ Terraform

  • Provider.tf To configure the provider, project and the backend for the terraform (Bucket).
  • Variables.tf All terraform variables types definiation.
    • Create variables without type to act as type any.
  • prod.tfvars Production variables.
📦 Modules
  1. apis module Enable and disable apis
  • Comopute api.
  • Container api.
  1. network module Configure network on GCP
  • Create VPC.
  • Partation the network using subnets.
  • Create route.
  • Create nat .
  • Configure firewall.
  1. cluster module Configure cluster
  • Create service account .
  • Create Cluster.
  • Create node pool with image type UBUNTU_CONTAINERD (Docker).
cd terraform 
terraform init
terraform terraform workspace new production
terraform plan --var-file=prod.tfvars
terraform apply --var-file=pord.tfvars 

🚢 Kubernetes

  • Starting the naming with number to make files ordered.
  • Create namespace to isolate the components.
  • Create role to enable the jenkins pod to create, list, delete services and deployments.
  • Create service account to be attached in the deployment.
  • Create role bind to bind the role with service account.
  • Create service loadbalancer to create loadbalacer with external ip to access the application.
  • Create deployment that contains:

    • Container with jenkins image with container port 8080.
    • Mount volume to use the Docker of the node.
    • Attach the service account to make pod create deployments and services in the same cluster
    • Execute commands to install docker cli and kubectl after pod started using lifecycle.
    • Create the pod with root privilege.

🔥 Script

Execute all kubernetes files

cd kubernetes
./apply.sh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.