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

Feature/25 update k8s readme #54

Merged
merged 74 commits into from
Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
bc3ae73
Update README.md
ayashbaral Dec 18, 2020
064439a
Update README.md
ayashbaral Dec 18, 2020
4de59ca
Update README.md
ayashbaral Dec 18, 2020
e90e36b
Update README.md
ayashbaral Dec 18, 2020
a060835
Update README.md
ayashbaral Dec 18, 2020
3539470
Update README.md
ayashbaral Dec 18, 2020
240b659
Merge branch 'main' into feature/25-update-k8s-readme
Dec 18, 2020
b57b5da
update reademe and added setup sh for windows
Dec 18, 2020
e1b8a11
Merge branch 'main' into feature/25-update-k8s-readme
Dec 18, 2020
a1449ce
install & boot minikube for darwin
devraghv Dec 18, 2020
0e48850
Install helm & off auto-update in homebrew
devraghv Dec 19, 2020
9dd3947
1. Method name change
devraghv Dec 19, 2020
511ebaf
Merge branch 'main' into feature/25-update-k8s-readme
Raghav2211 Dec 21, 2020
983678a
install helm for windows, remove debug log from minikube installation…
Dec 21, 2020
1016d45
updating readme to have individual readme file
Dec 21, 2020
cfbfbe8
updated readme
Dec 21, 2020
8b374bc
Update README.md
ayashbaral Dec 21, 2020
f60c8c9
Update README.md
ayashbaral Dec 21, 2020
161df16
Merge branch 'main' into feature/25-update-k8s-readme
Raghav2211 Dec 21, 2020
304722a
Merge branch 'main' into feature/25-update-k8s-readme
Raghav2211 Dec 21, 2020
ea881ce
Move environment folder to respective charts
devraghv Dec 21, 2020
6289ad0
update env folder in README
devraghv Dec 21, 2020
82a53a1
Remove env folder
devraghv Dec 21, 2020
6ac19a9
updated readme for mysql and updated values yaml
Dec 22, 2020
3c9a0b4
updated readme
Dec 22, 2020
e90731f
NoeAffinity policy dynamic based on env
devraghv Dec 22, 2020
be15412
remove invalid file
devraghv Dec 22, 2020
d9eb06a
Update README.md
ayashbaral Dec 22, 2020
fb63bfd
Update README.md
ayashbaral Dec 22, 2020
0948d90
Update README.md
ayashbaral Dec 22, 2020
65c2eed
Update README.md
ayashbaral Dec 22, 2020
623be87
Update README.md
ayashbaral Dec 22, 2020
c3c7506
Update README.md
ayashbaral Dec 22, 2020
b55b9c7
Update README.md
ayashbaral Dec 22, 2020
7e3471d
1. Add persistence.enabled to enable pvc
devraghv Dec 22, 2020
139f48f
Update README.md
ayashbaral Dec 22, 2020
af2737d
Update README.md
ayashbaral Dec 22, 2020
3808e03
Update README.md
ayashbaral Dec 22, 2020
3b64bd5
Required database variable
devraghv Dec 22, 2020
c2bf7a0
1. Update README
devraghv Dec 22, 2020
5571c0b
Correct path in README
devraghv Dec 22, 2020
6fd7cf8
Update README.md
ayashbaral Dec 22, 2020
7c3c700
Update README
devraghv Dec 22, 2020
1f36c61
Update README.md
ayashbaral Dec 22, 2020
892c928
Update README.md
ayashbaral Dec 22, 2020
2c34670
Update README.md
ayashbaral Dec 22, 2020
b3e9301
Update README.md
ayashbaral Dec 22, 2020
b00792e
Update README.md
ayashbaral Dec 22, 2020
ff1ca77
Update README.md
ayashbaral Dec 22, 2020
00e3f4d
Update README.md
ayashbaral Dec 22, 2020
6785865
Update README.md
ayashbaral Dec 22, 2020
bc2cf4f
Update README.md
ayashbaral Dec 22, 2020
f8e2329
Update README.md
ayashbaral Dec 22, 2020
7179e4d
Update README.md
ayashbaral Dec 22, 2020
f0a7b7a
Update README.md
ayashbaral Dec 22, 2020
3ac7345
Update README.md
ayashbaral Dec 22, 2020
023e1bc
chart and readme updated
Dec 22, 2020
066abcc
mysql db username password update
Dec 22, 2020
a2ed781
Update README.md
ayashbaral Dec 22, 2020
2a73b03
chart and read me update for todo-app
Dec 22, 2020
50850f6
1. Correct docker-compose yaml for mysql
devraghv Dec 22, 2020
4c7bbbb
Update configuration mysql
devraghv Dec 22, 2020
afec7d7
Add mysql rootpassword in docker-compose
devraghv Dec 22, 2020
fb3e39b
Correct secretkey name in deployment.yaml in mysql
devraghv Dec 22, 2020
3d12336
read me updated
Dec 22, 2020
9719755
Update docker deployment README
devraghv Dec 22, 2020
869e1c0
use(/var/lib/mysql) mysql container volume for persistent in docker d…
devraghv Dec 22, 2020
bdd324c
Update build.yml
Raghav2211 Dec 22, 2020
cb29c05
Update build.yml
Raghav2211 Dec 22, 2020
4ead907
Update build.yml
Raghav2211 Dec 22, 2020
f505c40
config update for psi-todo in k8s
Dec 22, 2020
dfcdb9b
correct todo config key name
devraghv Dec 23, 2020
03817b0
Remove dry-run for uninstall README
devraghv Dec 23, 2020
2f34618
1. Rename env secret file name
devraghv Dec 23, 2020
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
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