Skip to content

Commit

Permalink
Feature/25 update k8s readme (#54)
Browse files Browse the repository at this point in the history
* Update README.md

updated

* Update README.md

updated

* Update README.md

updated

* Update README.md

updated

* Update README.md

updated

* Update README.md

updated

* update reademe and added setup sh for windows

update reademe and added setup sh for windows

* install & boot minikube for darwin

* Install helm & off auto-update in homebrew

* 1. Method name change
2. Handle debug with 0 parameter

* install helm for windows, remove debug log from minikube installation in windows

i. install helm for windows
ii.remove debug log from minikube installation in windows

* updating readme to have individual readme file

updating readme to have individual readme file

* updated readme

* Update README.md

updated.

* Update README.md

updated

* Move environment folder to respective charts

* update env folder in README

* Remove env folder

* updated readme for mysql and updated values yaml

updated readme for mysql and updated values yaml

* updated readme

* NoeAffinity policy dynamic based on env

* remove invalid file

* Update README.md

updated.

* Update README.md

updated

* Update README.md

updated.

* Update README.md

updated

* Update README.md

updated

* Update README.md

updated.

* Update README.md

updated.

* 1. Add persistence.enabled to enable pvc
2. Add nodeaffinity in pv dynamic

* Update README.md

updated.

* Update README.md

updated.

* Update README.md

updated.

* Required database variable

* 1. Update README
2. Change mysql secret var name

* Correct path in README

* Update README.md

updated.

* Update README

* Update README.md

updated.

* Update README.md

updated.

* Update README.md

updated.

* Update README.md

updated

* Update README.md

updated.

* Update README.md

updated.

* Update README.md

updated.

* Update README.md

updated.

* Update README.md

updated.

* Update README.md

updated.

* Update README.md

updated.

* Update README.md

updated.

* Update README.md

updated.

* chart and readme updated

chart and readme updated

* mysql db username password update

mysql db username password update

* Update README.md

* chart and read me update for todo-app

chart and read me update for todo-app

* 1. Correct docker-compose yaml for mysql

* Update configuration mysql
1. Add root password
2. Add MYSQL_USER in mysql deployment env

* Add mysql rootpassword in docker-compose

* Correct secretkey name in deployment.yaml in mysql

* read me updated

read me updated

* Update docker deployment README
1. Add MYSQL_ROOT_PASSWORD

* use(/var/lib/mysql) mysql container volume for persistent in docker deployment

* Update build.yml

add failure result step if test local stack is fail

* Update build.yml

test failure step

* Update build.yml

remove test commit

* config update for psi-todo in k8s

config update for psi-todo in k8s

* correct todo config key name

* Remove dry-run for uninstall README

* 1. Rename env secret file name
2. Update README

Co-authored-by: Ayashkant Baral <[email protected]>
Co-authored-by: Raghav2211 <[email protected]>
Co-authored-by: neo <[email protected]>
  • Loading branch information
4 people authored Dec 23, 2020
1 parent 4689898 commit 19dd5bb
Show file tree
Hide file tree
Showing 31 changed files with 469 additions and 144 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ jobs:
run: |
sleep 120
docker run --network container:psi-todo appropriate/curl -s --retry 10 --retry-connrefused http://localhost:8080/actuator/health
- name: Failure Result
if: ${{ failure() }}
run: |
docker logs mysql
docker logs psi-todo
10 changes: 5 additions & 5 deletions todo-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ The following table lists the configurable parameters of the TodoApp swarm clust
`BASIC_AUTH_USERNAME` | Username of Basic-Auth | ``
`BASIC_AUTH_PASSWORD` | Password of Basic-Auth | ``
`MYSQL_IMAGE_TAG` | Image tag for Mysql | `8.0.22`
`MYSQL_USER` | Username of new user to create | `root`
`MYSQL_PASSWORD` | Password for the new user | `root`
`MYSQL_DATABASE` | Name for new database to create | `psi`
`MYSQL_DATA_SRC_PATH` | Host path for persistence mysql data | ``
`MYSQL_DATA_DEST_PATH` | Mount directory path in mysql container | `/var/lib/mysql`
`MYSQL_USER` | Username of new user to create | ``
`MYSQL_PASSWORD` | Password for the new user | ``
`MYSQL_ROOT_PASSWORD` | Password for the root user | ``
`MYSQL_DATABASE` | Name for new database to create | ``
`MYSQL_DATA_SRC_PATH` | Host path for persistence mysql data | ``
4 changes: 3 additions & 1 deletion todo-app/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ services:
psimysql:
image: mysql:${MYSQL_IMAGE_TAG}
environment:
MYSQL_USER: ${MYSQL_USER}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
psitodoapp:
image: psi-todo:${PSI_TODO_IMAGE_TAG:-latest}
depends_on:
Expand Down
8 changes: 4 additions & 4 deletions todo-app/env/ci/Docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Mysql variables
MYSQL_IMAGE_TAG=8.0.22
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=psi
MYSQL_DATA_DEST_PATH=/var/lib/mysql
MYSQL_USER=psi
MYSQL_PASSWORD=psi
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=psi
6 changes: 3 additions & 3 deletions todo-app/env/local/Docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ PSI_TODO_STACK_IMAGE=localhost:5000/psi-todo

# Mysql variables
MYSQL_IMAGE_TAG=8.0.22
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_USER=psi
MYSQL_PASSWORD=psi
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=psi
#MYSQL_DATA_SRC_PATH=
MYSQL_DATA_DEST_PATH=/var/lib/mysql
2 changes: 1 addition & 1 deletion todo-app/env/local/docker-compose-override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
psimysql:
container_name: mysql #Specify a custom container name, rather than a generated default name
volumes:
- mysql_data:${MYSQL_DATA_DEST_PATH}:cached # Strong consistency is quite expensive, requiring coordination between all of a files writers to guarantee
- mysql_data:/var/lib/mysql:cached # Strong consistency is quite expensive, requiring coordination between all of a files writers to guarantee
# they don’t inappropriately clobber each other’s changes
# So Relax consistency guarantees using `cached` mode (Don’t do this in production …)
psitodoapp:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"
services:
psimysql:
volumes:
- mysql_data:${MYSQL_DATA_DEST_PATH}:cached # Strong consistency is quite expensive, requiring coordination between all of a files writers to guarantee
- mysql_data:/var/lib/mysql:cached # Strong consistency is quite expensive, requiring coordination between all of a files writers to guarantee
# they don’t inappropriately clobber each other’s changes
# So Relax consistency guarantees using `cached` mode (Don’t do this in production …)
volumes:
Expand Down
13 changes: 13 additions & 0 deletions todo-app/k8s/ChocolateyInstallNonAdmin.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Set directory for installation - Chocolatey does not lock
# down the directory if not the default
$InstallDir='C:\ProgramData\chocoportable'
$env:ChocolateyInstall="$InstallDir"

# If your PowerShell Execution policy is restrictive, you may
# not be able to get around that. Try setting your session to
# Bypass.
Set-ExecutionPolicy Bypass -Scope Process -Force;

# All install options - offline, proxy, etc at
# https://chocolatey.org/install
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
2 changes: 2 additions & 0 deletions todo-app/k8s/CreateInternalSwitch.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Create an internal switch
New-VMSwitch -name minikube -SwitchType Internal
5 changes: 5 additions & 0 deletions todo-app/k8s/EnableHyperV.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Check and Enable Hyper-V If not enabled
if ((Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online).State -ne 'Enabled')
{
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
}
63 changes: 29 additions & 34 deletions todo-app/k8s/README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,50 @@
# Deploy Todo Application in K8s cluster using helm
# Deploy Todo Application to K8s cluster using helm

- Setup minikube
https://minikube.sigs.k8s.io/docs/start/
- Local Deployment

## Local Deployment ##

- Setup minikube

Install Dependencies and run minikube

```bash
bash setup.sh bootlocal
```

- Link host docker client to the VM's docker daemon
```bash
eval $(minikube docker-env)
```
```bash
eval $(minikube docker-env)
```
- Build
[Build & Create Docker Image](../README.md#build)
- Deploy mysql

```bash
helm install mysql ./mysql -f env/<env>/mysql-secret.yaml
```
or

```bash
helm install mysql ./mysql -f env/<env>/mysql-secret.yaml -f env/<env>/mysql-values.yaml
```
[Deploy MySql using helm](mysql/README.md#Installing%20the%20Chart)
- Deploy Todo-app
```bash
helm install psi-todo ./psi-todo
```
or

```bash
helm install psi-todo ./psi-todo -f env/<env>/psi-todo-secret.yaml -f env/<env>/psi-todo-values.yaml
```
[Deploy Todo App using helm](psi-todo/README.md#Installing%20the%20Chart)
- Verify all pods are up and running
```bash
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
psi-todo-6f4f69b7d7-8t8kg 1/1 Running 0 92m
mysql-58b87bf444-pshmk 1/1 Running 0 92m
```
```bash
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
psi-todo-6f4f69b7d7-8t8kg 1/1 Running 0 92m
mysql-58b87bf444-pshmk 1/1 Running 0 92m
```
- Execute below command in a separate terminal which creates a route to services deployed with type LoadBalancer and sets their Ingress to their ClusterIP.
```bash
minikube tunnel
```
```bash
minikube tunnel
```
- Access swagger api endpoint with below url.
http://localhost:8080/swagger-ui/
http://localhost:8080/swagger-ui/
3 changes: 0 additions & 3 deletions todo-app/k8s/env/local/mysql-secret.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions todo-app/k8s/env/local/mysql-values.yaml

This file was deleted.

77 changes: 77 additions & 0 deletions todo-app/k8s/mysql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# MySql Helm Chart


## Introduction

This chart bootstraps a single node MySQL deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.19.2
- PV provisioner support in the underlying infrastructure

## Installing the Chart

To install the chart with the release name `mysql` with respective environment secret file:

```bash
# Verify the configuration
$ helm install --dry-run --debug mysql mysql -f mysql/env/<env>/secrets.yaml

# Install chart
$ helm install mysql mysql -f mysql/env/<env>/secrets.yaml
```

To install the chart with the release name `mysql` with respective environment secret and configuration file:

```bash
# Verify the configuration
$ helm install --dry-run --debug mysql mysql -f mysql/env/<env>/secrets.yaml -f mysql/env/<env>/values.yaml

# Install chart
$ helm install mysql mysql -f mysql/env/<env>/secrets.yaml -f mysql/env/<env>/values.yaml
```

## Uninstalling the Chart

To uninstall/delete the `mysql` deployment:

```bash
$ helm uninstall mysql
```

## Configuration

The following table lists the configurable parameters of the MySQL chart and their default values.

| Parameter | Description | Default |
| -------------------------------------------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| `replica` | Number of instance to run at any time | 1 |
| `image` | `mysql` image configuration. | ` ` |
| `image.repository` | `mysql` image repository. | `mysql`|
| `image.pullPolicy` | `mysql` image pull policy. | `IfNotPresent`|
| `image.tag` | `mysql` image tag. | `8.0.22`|
| `service` | `mysql` service configuration | ` ` |
| `service.type` | Kubernetes service type | `ClusterIP`|
| `service.port` | Service Port to be exposed outside | 3306 |
| `resources` | `mysql` CPU/Memory resource requests/limits | `{}` |
| `persistence` | persistence is to recover data after pod kill | `{}` |
| `persistence.enabled` | persistence is enabled or not | `false ` |
| `persistence.storageClass` | Type of persistent volume claim | ` ` |
| `persistence.accessMode` | ReadWriteOnce or ReadOnly | ` ` |
| `persistence.size` | Size of persistent volume claim | ` ` |
| `persistence.hostPath` | HostPath of the volume to mount | ` ` |
| `config` | Configuration for mysql | `{ database: psi }` |
| `config.database` | Database name | `psi`|
| `username` | Database user name | ` ` |
| `password` | Database password | ` ` |
| `rootPassword` | Database root user password | ` ` |
| `nodeAffinity` | Assign Pods to Nodes using Node Affinity | `[]` |



## Persistence

A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes. It is a resource in the cluster just like a node is a cluster resource. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual Pod that uses the PV, so even if the application pod gets down still the backend data will be retained and when applicatin pod will be up then , persisted data can be accessed.

PersistentVolume will be created if `persistence.enabled` is set to `true` and if true then data will be mounted into specified directory. In order to disable this functionality `persistence.enabled` should be set to `false`.
4 changes: 4 additions & 0 deletions todo-app/k8s/mysql/env/local/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
username: psi
password: psi
rootPassword: root

16 changes: 16 additions & 0 deletions todo-app/k8s/mysql/env/local/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- minikube

persistence:
enabled: true
storageClass: local
accessMode:
- ReadWriteOnce
size: 1Gi
hostPath: /mnt/data
5 changes: 4 additions & 1 deletion todo-app/k8s/mysql/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
release: "{{ .Release.Name }}"
data:
url: {{ template "mysql.fullname" . }}
{{- range $key, $val := .Values.mysqlConfig }}
{{- if not .Values.config.database }}
{{- fail "Database name is required" }}
{{- end }}
{{- range $key, $val := .Values.config }}
{{ $key }}: {{ $val | quote }}
{{- end }}
Loading

0 comments on commit 19dd5bb

Please sign in to comment.