Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile documentation #16

Merged
merged 9 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ help:
@echo ' make destroy Destroy all GCP resources.'
@echo ' make validate Check that installed resources work as expected.'
@echo ' make lint Check syntax of all scripts.'
@echo ' make get pods Get running pods IP's and Namespaces run this command after apply'
@echo ' make getpods Get running pods IPs and Namespaces run this command after apply'
@echo

# Before you run this command please export the required variables.
Expand Down Expand Up @@ -56,12 +56,12 @@ validate:
bash ${ROOT}/scripts/validate.sh

# Get pods details of the running container cluster.
.PHONY: get pods
get pods:
.PHONY: getpods
getpods:
python ${ROOT}/test/kube-pods.py

.PHONY: lint
lint: Check_shell check_terraform check_shebangs check_trailing_whitespace
lint: check_shell check_terraform check_shebangs check_trailing_whitespace

# Shell check
.PHONY: check_shell
Expand Down
63 changes: 61 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ A [Terraform Module](https://www.terraform.io/docs/language/modules/develop/inde

Instead of figuring out the details of how to run a piece of infrastructure from scratch, you can reuse existing code that has been proven in production. And instead of maintaining all that infrastructure code yourself, you can leverage the work of the Module to pick up infrastructure improvements through a version number bump.

## Prerequisites
At a minimum 61 GiB of memory, 8 vCPUs virtual machines are needed to run k8ssandra. Minimum recommendation for volumes is 1.5 - 2 TB, but that's all set up through the persistent volume requests.

## GCP Prerequisites
### GCP Prerequisites

| NAME | Version |
|-------------------|------------|
Expand Down Expand Up @@ -92,12 +94,69 @@ k8ssandra-terraform/
| README.md
</pre>

* How to use Makefile
* `make help` To list out the available options to use.
* `make init` Initialize and configure Backend.
* `make plan` Plan all GCP resources.
* `make apply` Create or update GCP resources.
* `make destroy` Destroy all GCP resources.
* `make validate` Check that installed resources work as expected.
* `make lint` Check syntax of all scripts.
* `make getpods` Get running pods IPs and Namespaces run this command after apply

## Create GKE resources

* Testing this project Locally [gcp](./gcp#test-this-project-locally)

* Set up environment on your machine before running the make commands. use the following links to setup your machine.
* [Tools](./gcp#Tools)
* [GCP-authentication](./gcp#GCP-authentication)
* [Configure-gcloud-settings](./gcp/#Configure-gcloud-settings)

* How to create GKE cluster resources by using the make command
[ WORK IN PROGRESS ]
Before using the make commands export the following terraform environment variables(TFVARS) for terraform to create the resources.

```console

export TF_VAR_environment=<ENVIRONMENT_REPLACEME>
ex:- export TF_VAR_environment=dev

export TF_VAR_name=<CLUSTERNAME_REPLACEME>
ex:- export TF_VAR_name=k8ssandra

export TF_VAR_project_id=<PROJECTID_REPLACEME>
ex:- export TF_VAR_project_id=k8ssandra-testing

export TF_VAR_region=<REGION_REPLACEME>
ex:- export TF_VAR_region=us-central-1

```

```console
#To list out the available options to use.
make help
```
### important: Before running the following command, we need to Export the environment variables as show above.

```console
# Initialize and configure Backend.
make init
```
```console
# Plan all GCP resources.
make plan
```
### This command will create a Kubernetes cluster and deploy k8ssandra on the cluster.
```console
# Create or update GCP resources
# This command takes some time to execute.
make apply
```
```console
# Destroy all GCP resources

make destroy
```

## Create EKS resources

Expand Down
35 changes: 19 additions & 16 deletions gcp/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# K8ssandra GCP Terraform Example

## What is Google Kubernetes Engine (GKE)?
[Google Kubernetes Engine](https://cloud.google.com/kubernetes-engine) or "GKE" is a Google-managed Kubernetes environment. GKE is a fully managed experience; it handles the management/upgrading of the Kubernetes cluster master as well as autoscaling of "nodes" through "node pool" templates.
[Google Kubernetes Engine](https://cloud.google.com/kubernetes-engine) or "GKE" is a Google-managed Kubernetes environment. GKE is a fully managed experience; it handles the management/upgrading of the Kubernetes cluster master as well as Autoscaling of "nodes" through "node pool" templates.

Through GKE, your Kubernetes deployments will have first-class support for GCP IAM identities, built-in configuration of high-availability and secured clusters, as well as native access to GCP's networking features such as load balancers.

## What is GKE Node Pool ?
GKE Node Pools are a group of nodes who share the same configuration, defined as a NodeConfig. Node pools also control the autoscaling of their nodes, and autoscaling configuration is done inline, alongside the node config definition. A GKE Cluster can have multiple node pools defined. Initially by default we have only defined a `1` node pool.
GKE Node Pools are a group of nodes who share the same configuration, defined as a NodeConfig. Node pools also control the Autoscaling of their nodes, and Autoscaling configuration is done inline, alongside the node config definition. A GKE Cluster can have multiple node pools defined. Initially by default we have only defined a `1` node pool.

## VPC Network
You must explicitly specify the network and subnetwork of your GKE cluster using the network and subnetwork fields; We will not use the default network with an automatically generated subnetwork.
Expand All @@ -16,16 +16,13 @@ You must explicitly specify the network and subnetwork of your GKE cluster using
* GKE cluster
* Cluster node pool
* Service account
* Iam member
* Custom Iam member
* Iam members
* Google compute network(VPC)
* Public subnet
* Private subnet
* Subnet
* Router
* Compute router NAT
* Google storage bucket
* Google storage bucket IAM member
* Google compute address


## Project directory Structure
Expand Down Expand Up @@ -85,7 +82,7 @@ The steps to create kubernetes cluster in this document require the following to

### Cloud project

You will need a google cloud project created, If you do not have a google cloud account plese sigup [google](https://cloud.google.com).
You will need a google cloud project created, If you do not have a google cloud account please signup [google](https://cloud.google.com).

### Required GCP APIs

Expand All @@ -104,6 +101,9 @@ Execute the following commands on the linux machine in order to setup gcloud cli
```console
gcloud init
```
### GCP Quotas

If you created your Google cloud account newly, Google Compute Engine enforces quotas on resource usage for a variety of reasons. For example, quotas protect the community of Google Cloud users by preventing unforeseen spikes in usage, Google keep some soft limitations on the resources, you can always make a request to increase your quota limit. If you are planning to deploy k8ssandra cluster on GKE, you will need to make a request to increase your **Compute Engine API (backend services)** quota to `50` for the future use.
bradfordcp marked this conversation as resolved.
Show resolved Hide resolved

### Tools

Expand All @@ -121,26 +121,29 @@ Terraform is used to automate the manipulation of cloud infrastructure. Its [Ter

The Google Cloud SDK is used to interact with your GCP resources. [Google cloud SDK Installation instructions](https://cloud.google.com/sdk/downloads) for multiple platforms are available online.

#### Install kubectl CLI

The kubectl CLI is used to interteract with both Kubernetes Engine and Kubernetes in general. [kubectl CLI Installation instructions](https://cloud.google.com/kubernetes-engine/docs/quickstart) for multiple platforms are available online.


### GCP authenticaion
### GCP-authentication

Ensure you have authenticated your gcloud client by running the following command:

```console
gcloud auth login
```

if you are already using another profile on your machine, use the following command to update the credentials:
If you are already using another profile on your machine, use the following command to update the credentials:

```console
gcloud auth application-default login
```
#### Install Kubectl
The kubectl CLI is used to interact with both Kubernetes Engine and Kubernetes in general. Use the following command to install kubectl using gcloud:

```console
# install Kubectl
gcloud components install kubectl.
```

### Configure gcloud settings
### Configure-gcloud-settings

Run `gcloud config list` and make sure that `compute/zone`, `compute/region` and `core/project` are populated with values that work for you. You can choose a [region and zone near you](https://cloud.google.com/compute/docs/regions-zones/). You can set their values with the following commands:

Expand Down Expand Up @@ -184,7 +187,7 @@ ex:- export TF_VAR_region=us-central-1

```

Importent: Initialize the terraform modules delete the backend file for local testing.
Important: Initialize the terraform modules delete the backend file for local testing.

```console
cd env/
Expand Down
12 changes: 0 additions & 12 deletions gcp/modules/vpc/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,3 @@ output "network_selflink" {
output "subnetwork_selflink" {
value = google_compute_subnetwork.compute_subnetwork.self_link
}

/*
# Output variable for the NAT address selflink.
output "compute_address" {
value = google_compute_address.compute_address.self_link
}

# Output variable for the NAT ip address.
output "compute_address_id" {
value = google_compute_address.compute_address.id
}
*/
13 changes: 12 additions & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# Scripts to create and destroy the resources
[ WORK IN PROGRESS ]

## What's in this folder

* [apply.sh](./apply.sh): By using this script we can apply changes to the Terraform resources in GCP.
* [common.sh](./common.sh): By using this script we can validate the required packages and variables on your system. This script will be called in `apply.sh`, `init.sh`, `validate.sh`, `destroy.sh`, `plan.sh`.
* [delete_bucket.py](./delete_bucket.py): By using this script we can delete the GCP bucket created for terraform state files.
* [destroy.sh](./destroy.sh): By using this script we can destroy all the resource Created Terraform.
* [enable.sh](./enable.sh): By using this script we can enable the google api's
* [init.sh](./init.sh): By using this script we can initialize the modules, Terraform workspace, environment and create terraform statefile bucket.
* [make_bucket.py](./make_bucket.py): This script is used by [init.sh](./init.sh) to create terraform Statefiles bucket in GCP.
* [plan.sh](./plan.sh): By using this script we plan the resources by running `terraform plan` command.
* [validate.sh](./validate.sh): By using this script we can validate the Terraform code.
2 changes: 1 addition & 1 deletion scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ command -v terraform >/dev/null 2>&1 || { \

# Make sure python3 is installed. If not, refer to:
# https://www.python.org/downloads/
command -v terraform >/dev/null 2>&1 || { \
command -v python3 >/dev/null 2>&1 || { \
echo >&2 "I require python3 but it's not installed. Aborting."
echo >&2 "https://www.python.org/downloads/"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

This folder the contains [lint.sh](./lint.sh) script. To check the linting on all type project files on this repository.

[ WORK IN PROGRESS ]

14 changes: 14 additions & 0 deletions test/reper-nodeport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: reaper-nodeport
spec:
ports:
- name: app
port: 8080
protocol: TCP
targetPort: 8080
selector:
app.kubernetes.io/managed-by: reaper-operator
reaper.cassandra-reaper.io/reaper: test-reaper
type: NodePort