Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carlohcs/kubernetes-ci-cd-github-actions
This project is a comprehensive guide to implementing CI/CD pipelines for Kubernetes using GitHub Actions. It covers everything from setting up a Kubernetes cluster to automating the deployment process with GitHub Actions.
https://github.com/carlohcs/kubernetes-ci-cd-github-actions
actions github-actions k8s kubernetes
Last synced: about 1 month ago
JSON representation
This project is a comprehensive guide to implementing CI/CD pipelines for Kubernetes using GitHub Actions. It covers everything from setting up a Kubernetes cluster to automating the deployment process with GitHub Actions.
- Host: GitHub
- URL: https://github.com/carlohcs/kubernetes-ci-cd-github-actions
- Owner: carlohcs
- Created: 2024-08-03T19:47:55.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-12T18:53:36.000Z (3 months ago)
- Last Synced: 2024-09-30T23:23:51.137Z (about 2 months ago)
- Topics: actions, github-actions, k8s, kubernetes
- Language: Astro
- Homepage:
- Size: 363 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kubernetes with CI/CD and GitHub Actions
![Running application example](./docs/hello-world.png)
This project is a comprehensive guide to implementing CI/CD pipelines for Kubernetes using GitHub Actions.
It covers everything from setting up a Kubernetes cluster to automating the deployment process with GitHub Actions.
Whether you're new to Kubernetes or looking to enhance your existing CI/CD workflows, this guide provides step-by-step instructions and best practices to streamline your development process.
With the power of GitHub Actions, you can easily automate the building, testing, and deployment of your Kubernetes applications, ensuring faster and more reliable releases.
Get started today and take your CI/CD to the next level with Kubernetes and GitHub Actions.
## Disambiguation
**CI (Continuous Integration)** is the practice of automating the integration of code changes from multiple contributors into a project.
**CD (Continuous Delivery)** is the practice of automating the delivery of changed code to production environments, ensuring that the software is always deployable.
## Steps
### On your cloned version of this repository
Change the data:
- Cluster name;
- Docker username;
- Docker image name;In [.github/workflows/cd.yml](.github/workflows/cd.yml)
Change the data:
- Image name;
In [k8s/node-deployment.yaml](k8s/node-deployment.yaml)
### On Amazon
- Create a cluster, eg.:
- ![Cluster example](./docs/cluster.jpeg)
- Create a node linked to this cluster, eg.:
- ![Node example](./docs/node.jpeg)
- Get the data from:
- `AWS_ACCESS_KEY_ID`;
- `AWS_SECRET_ACCESS_KEY`;
- `AWS_SESSION_TOKEN`
- Within default account: [https://stackoverflow.com/a/37947853/3929980](https://stackoverflow.com/a/37947853/3929980)
- Within AWS Academy:
- `AWS Details` > `AWS CLI` > `Show`### On Google
#### Locally
1. Ensure:
- you have `gcloud` installed: [https://cloud.google.com/sdk/docs/install](https://cloud.google.com/sdk/docs/install) or [https://cloud.google.com/sdk/docs/downloads-interactive](https://cloud.google.com/sdk/docs/downloads-interactive)
- you are logged in: `gcloud auth login`
- you are in a project: `gcloud config set project ` eg.: `gcloud config set project thermal-micron-427901-e1`2. Create a GKE Cluster:
```bash
gcloud container clusters create $GKE_CLUSTER \
--project=$GKE_PROJECT \
--zone=$GKE_ZONE
```eg.:
```bash
export GKE_CLUSTER=my-cluster; export GKE_PROJECT=thermal-micron-427901-e1; export GKE_ZONE=us-east1; gcloud container clusters create $GKE_CLUSTER --project=$GKE_PROJECT --zone=$GKE_ZONE --disk-type pd-standard --num-nodes=1 --machine-type=e2-micro --node-locations=us-east1-b
```* `--num-nodes` reduce the number of nodes; `---machine-type` define cpu resources;
* `--node-locations` define number of available zones;
* `--disk-type pd-standard` prevents the error about quota)3. Follow [https://docs.github.com/en/actions/use-cases-and-examples/deploying/deploying-to-google-kubernetes-engine](https://docs.github.com/en/actions/use-cases-and-examples/deploying/deploying-to-google-kubernetes-engine) until before `Creating the workflow` topic.
## On Docker Hub
- Create a Personal Access Token - [https://app.docker.com/settings/personal-access-tokens/create](https://app.docker.com/settings/personal-access-tokens/create)
## On GitHub
With the cloned version of this repository, go to your repository and Settings:
- `Security` > `Actions`;
- Go to `Secrets` tab, `New repository secret`:
- ![Secrets example](./docs/secrets-github.jpeg)
- Add the following tokens with the previous captured values:
- `AWS_ACCESS_KEY_ID`;
- `AWS_SECRET_ACCESS_KEY`;
- `AWS_SESSION_TOKEN`;
- `DOCKERHUB_TOKEN`.## When developing
When a commit is made, if everything is correct, we see the images:
- Commit checks:
- ![Secrets example](./docs/all-builds-are-ok.jpeg)
- CI
- ![CI](./docs/ci.png)
- CD:
- ![CD](./docs/cd.jpeg)### Tips
### Building the image locally
```bash
docker build . -t carlohcs/kubernetes-ci-cd-github-actions
```### Running the application locally (after image build)
```bash
docker run -p 3000:3000 carlohcs/kubernetes-ci-cd-github-actions
```### GKE - Best zone
[https://googlecloudplatform.github.io/region-picker/](https://googlecloudplatform.github.io/region-picker/)
---
Enjoy!