Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miou-zora/whanos
Gcp project creator using Terraform, Kubernetes, Ansible, Jenkins, Helm, Docker
https://github.com/miou-zora/whanos
ansible docker helm jenkins k8s kubernetes terraform
Last synced: 11 days ago
JSON representation
Gcp project creator using Terraform, Kubernetes, Ansible, Jenkins, Helm, Docker
- Host: GitHub
- URL: https://github.com/miou-zora/whanos
- Owner: Miou-zora
- Created: 2024-05-04T21:15:28.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-05-04T21:16:05.000Z (9 months ago)
- Last Synced: 2024-12-04T09:06:41.373Z (2 months ago)
- Topics: ansible, docker, helm, jenkins, k8s, kubernetes, terraform
- Language: HCL
- Homepage:
- Size: 90.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Prerequisites
First of all, you need to have a google account and a google cloud project. If you don't have one, you can create one [here](https://console.cloud.google.com/).
You also have to enable billing for your project. You can find more information [here](https://cloud.google.com/billing/docs/how-to/modify-project).Then, you need to create a service account name "terraform@`$project_id`.iam.gserviceaccount.com" with the following roles:
![Alt text](docs/image.png)
You can find more information [here](https://cloud.google.com/iam/docs/creating-managing-service-accounts).
Finally, you need to create a key for this service account and download it in json format. You can find more information [here](https://cloud.google.com/iam/docs/creating-managing-service-account-keys). This key will be used by terraform to create the infrastructure, so keep it safe.
On gcp, you also need to enable the following APIs:
- Artifact Registry API
- Compute Engine API
- Identity and Access Management (IAM) API (you have already done it if you have created the service account)
- Kubernetes Engine API# Deployement
## Terraform
First, you need to install terraform. You can find the installation instructions [here](https://learn.hashicorp.com/tutorials/terraform/install-cli).
Then, you need to create a file named `variables.tfvars` with the following content (you can find values on GCP):
```terraform
project_id = "your_project_id"
project_region = "your_project_region"
credentials_file = "path_to_your_credentials_file"
machine_type="your machine type"
machine_zone="your machine zone"
```For kubernetes, you need to copy this file in kubernetes/terraform directory.
Put your credentials file in the terraform directory.
Finally, you can run the following commands (in the terraform directory):
```bash
terraform init
terraform apply --var-file="variables.tfvars"
```Now, you have your compute engine instance and your kubernetes cluster. You can connect to the compute engine instance with the following command (optional):
```bash
gcloud compute ssh --project $project_id --zone $machine_zone jenkins-server
```## Ansible
First, you need to install ansible. You can find the installation instructions [here](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html).
Then, you need to create a file named `inventory.yml` with the following content:
```yaml
all:
children:
jenkins:
hosts:
jenkins-1:
ansible_user: "your_compute_engine_instance_ssh_user"
ansible_host: "your_compute_engine_instance_ip"
```Put it in the ansible directory.
Create user admin password:
```bash
ansible-vault encrypt_string 'admin_password' --name 'USER_ADMIN_PASSWORD' (change 'admin_password' with your password)
```Create a file named `group_vars/all.yml` with the following content:
```yaml
GOOGLE_KEY: "path_to_your_credentials_file" (same as terraform)
USER_ADMIN_PASSWORD: "your_password" (you previously created it with ansible-vault)
```Put it in the ansible directory.
Create a file named `.env` with the following content:
```bash
REGION= "your project region on gcp"
PROJECT_NAME= "your project name on gcp"
```Put it in the ansible/roles/jenkins/files directory.
Then run the following command (in the ansible directory):
```bash
ansible-playbook -i inventory.yml playbook.yml
```Now, you have your jenkins server with docker and kubectl installed.
## Jenkins
First, you need to connect to the jenkins server. Open web browser and go to `http://your_compute_engine_instance_ip:8080`. You can now connect to jenkins with the following credentials:
- username: admin
- password: "the password you have set in the ansible var file"Now, enjoy your jenkins server !