Skip to content

Commit

Permalink
Merge pull request #17 from cherrymu/hello-world-app
Browse files Browse the repository at this point in the history
added makefile and updated readme file
  • Loading branch information
cherrymu authored Aug 22, 2024
2 parents b15480f + d267b5b commit 416affd
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 8 deletions.
81 changes: 81 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Makefile to install Docker, KIND, OpenTofu, Cosign, kubectl, and Helm

# Variables
KUBECTL_VERSION = v1.30.3
KIND_VERSION = v0.20.0
COSIGN_VERSION = v2.4.0
TOFU_VERSION = v1.8.1
HELM_VERSION = v3.15.3

# Targets
.PHONY: all docker kind opentofu cosign kubectl helm

all: docker kind opentofu cosign kubectl helm

docker:
@echo "Installing Docker..."
@curl -fsSL https://get.docker.com -o get-docker.sh
@sh get-docker.sh
@sudo usermod -aG docker $$USER
@rm get-docker.sh
@echo "Docker installed successfully."

kind:
@echo "Installing KIND..."
@curl -Lo ./kind https://kind.sigs.k8s.io/dl/$(KIND_VERSION)/kind-linux-amd64
@chmod +x ./kind
@sudo mv ./kind /usr/local/bin/kind
@echo "KIND installed successfully."

opentofu:
@echo "Installing Tofu CLI..."
@wget --secure-protocol=TLSv1_2 --https-only https://get.opentofu.org/install-opentofu.sh -O install-opentofu.sh
@chmod +x install-opentofu.sh
@sh install-opentofu.sh --install-method standalone
@rm -f install-opentofu.sh
@echo "Tofu CLI installed successfully."


cosign:
@echo "Installing Cosign..."
@curl -Lo ./cosign https://github.com/sigstore/cosign/releases/download/$(COSIGN_VERSION)/cosign-linux-amd64
@chmod +x ./cosign
@sudo mv ./cosign /usr/local/bin/cosign
@echo "Cosign installed successfully."

kubectl:
@echo "Installing kubectl..."
@curl -LO "https://dl.k8s.io/release/$(KUBECTL_VERSION)/bin/linux/amd64/kubectl"
@chmod +x ./kubectl
@sudo mv ./kubectl /usr/local/bin/kubectl
@echo "kubectl installed successfully."

helm:
@echo "Installing Helm..."
@curl -Lo helm.tar.gz https://get.helm.sh/helm-$(HELM_VERSION)-linux-amd64.tar.gz
@tar -zxvf helm.tar.gz
@sudo mv linux-amd64/helm /usr/local/bin/helm
@rm -rf linux-amd64 helm.tar.gz
@echo "Helm installed successfully."

clean:
@echo "Cleaning up installed binaries..."
@sudo rm -f /usr/local/bin/kind
@sudo rm -f /usr/local/bin/opentofu
@sudo rm -f /usr/local/bin/cosign
@sudo rm -f /usr/local/bin/kubectl
@sudo rm -f /usr/local/bin/helm
@echo "Cleanup done."

help:
@echo "Makefile to install Docker, KIND, OpenTofu, Cosign, kubectl, and Helm."
@echo "Usage:"
@echo " make all Install all tools."
@echo " make docker Install Docker."
@echo " make kind Install KIND."
@echo " make opentofu Install OpenTofu."
@echo " make cosign Install Cosign."
@echo " make kubectl Install kubectl."
@echo " make helm Install Helm."
@echo " make clean Remove installed binaries."
@echo " make help Display this help message."
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
# Go Http Web Server
A simple http web server written in `Golang` exposing application metrics as a microservice. This project is built on the basic DevOps principles like building images securely through CI mechanism which includes signing of images, scanning for vulnerabilities and also does a continuous deployment test on every push and pull request. The application can be deployed easily on your kubernetes cluster using helm chart.

## Pre-requisites for installation
## Pre-requisites for installation on Linux Machines

- [Docker](https://docs.docker.com/desktop/)
- [KIND](https://kind.sigs.k8s.io/)
- [OpenTofu CLI](https://opentofu.org/docs/intro/install/)
- [OpenTofu](https://opentofu.org/docs/intro/install/)
- [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/)
- [Helm](https://helm.sh)
- [Cosign](https://docs.sigstore.dev/cosign/installation)

## Setup Quick KIND environment using OpenTofu
## Setup tools and environment using OpenTofu
1. Clone this repo in your local laptop
```bash
git clone https://github.com/cherrymu/process-out-challenge.git
```
2. switch directory into environments/local-dev
2. Install all the necessary cli tools using makescript. Before running the makefile please make sure you have `make` and `unzip` utility installed on your machine
```bash
make all
```
3. Switch directory into environments/local-dev
```bash
cd environments/local-dev/
```
3. Initialize OpenTofu
4. Initialize OpenTofu
```bash
tofu init
```
4. Apply OpenTofu Configuration to Create Kind Cluster
5. Apply OpenTofu Configuration to Create Kind Cluster
```bash
tofu apply -auto-approve
```
5. Set your `KUBECONFIG` path and check the status of the nodes
6. Set your `KUBECONFIG` path and check the status of the nodes
```bash
export KUBECONFIG=./environments/local-dev/kubeconfig_example

kubectl get nodes -o wide
```
6. Create a namespace for our application deployment and an `imagepull secret` to securely pull a private image from the container registry
7. Create a namespace for our application deployment and an `imagepull secret` to securely pull a private image from the container registry
```bash
kubectl create ns go-web-app

Expand Down

0 comments on commit 416affd

Please sign in to comment.