-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kalyan Reddy Daida
authored and
Kalyan Reddy Daida
committed
Jun 18, 2020
1 parent
5d4ceae
commit b37bdc1
Showing
92 changed files
with
1,182 additions
and
141 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
04-EKS-Storage-with-EBS-ElasticBlockStore/04-01-Install-EBS-CSI-Driver/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# EKS Storage with EBS - Elastic Block Store | ||
|
||
## Step-01: Introduction | ||
- Create IAM Policy for EBS | ||
- Associate IAM Policy to Worker Node IAM Role | ||
- Install EBS CSI Driver | ||
|
||
## Step-02: Create IAM policyy | ||
- Go to Services -> IAM | ||
- Create a Policy | ||
- Select JSON tab and copy paste the below JSON | ||
```json | ||
|
||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"ec2:AttachVolume", | ||
"ec2:CreateSnapshot", | ||
"ec2:CreateTags", | ||
"ec2:CreateVolume", | ||
"ec2:DeleteSnapshot", | ||
"ec2:DeleteTags", | ||
"ec2:DeleteVolume", | ||
"ec2:DescribeInstances", | ||
"ec2:DescribeSnapshots", | ||
"ec2:DescribeTags", | ||
"ec2:DescribeVolumes", | ||
"ec2:DetachVolume" | ||
], | ||
"Resource": "*" | ||
} | ||
] | ||
} | ||
``` | ||
- Review the same in **Visual Editor** | ||
- Click on **Review Policy** | ||
- **Name:** Amazon_EBS_CSI_Driver | ||
- **Description:** Policy for EC2 Instances to access Elastic Block Store | ||
- Click on **Create Policy** | ||
|
||
## Step-03: Get the IAM role Worker Nodes using and Associate this policy to that role | ||
``` | ||
# Get Worker node IAM Role ARN | ||
kubectl -n kube-system describe configmap aws-auth | ||
# from output check rolearn | ||
rolearn: arn:aws:iam::180789647333:role/eksctl-eksdemo1-nodegroup-eksdemo-NodeInstanceRole-IJN07ZKXAWNN | ||
``` | ||
- Go to Services -> IAM -> Roles | ||
- Search for role with name **eksctl-eksdemo1-nodegroup** and open it | ||
- Click on **Permissions** tab | ||
- Click on **Attach Policies** | ||
- Search for **Amazon_EBS_CSI_Driver** and click on **Attach Policy** | ||
|
||
## Step-04: Deploy Amazon EBS CSI Driver | ||
- Verify kubectl version, it should be 1.14 or later | ||
``` | ||
kubectl version --client --short | ||
``` | ||
- Deploy Amazon EBS CSI Driver | ||
``` | ||
kubectl apply -k "github.com/kubernetes-sigs/aws-ebs-csi-driver/deploy/kubernetes/overlays/stable/?ref=master" | ||
``` |
63 changes: 63 additions & 0 deletions
63
04-EKS-Storage-with-EBS-ElasticBlockStore/04-02-SC-PVC-ConfigMap-MySQL/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Kubernetes Storage - Storage Classes, Persistent Volume Claims | ||
|
||
|
||
## Step-01: Introduction | ||
| Kubernetes Object | YAML File | | ||
| ------------- | ------------- | | ||
| Storage Class | 01-storage-class.yml | | ||
| Persistent Volume Claim | 02-persistent-volume-claim.yml | | ||
| Config Map | 03-UserManagement-ConfigMap.yml | | ||
| Deployment, Environment Variables, Volumes, VolumeMounts | 04-mysql-deployment.yml | | ||
| ClusterIP Service | 05-mysql-clusterip-service.yml | | ||
|
||
## Step-02: Create following Kubernetes manifests | ||
- Storage Class | ||
- Persistent Volume Claim | ||
- ConfigMap | ||
- MySQL Deployment | ||
- Environment Variables | ||
- Volumes | ||
- Volume Mounts | ||
- MySQL ClusterIP Service | ||
|
||
## Step-02: Create MySQL Database with all above manifests | ||
``` | ||
# Create MySQL Database | ||
kubectl apply -f kube-manifests/ | ||
# List Storage Classes | ||
kubectl get sc | ||
# List PVC | ||
kubectl get pvc | ||
# List PV | ||
kubectl get pv | ||
# List pods | ||
kubectl get pods | ||
# List pods based on label name | ||
kubectl get pods -l app=mysql | ||
``` | ||
|
||
## Step-04: Connect to MySQL Database | ||
``` | ||
# Connect to MYSQL Database | ||
kubectl run -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql -ppassword | ||
``` | ||
|
||
|
||
|
||
|
||
## References: | ||
- **Dynamic Volume Provisioning:** https://kubernetes.io/docs/concepts/storage/dynamic-provisioning/ | ||
- https://github.com/kubernetes-sigs/aws-ebs-csi-driver/tree/master/deploy/kubernetes/overlays/stable | ||
- https://docs.aws.amazon.com/eks/latest/userguide/ebs-csi.html | ||
- https://github.com/kubernetes-sigs/aws-ebs-csi-driver | ||
- https://github.com/kubernetes-sigs/aws-ebs-csi-driver/tree/master/examples/kubernetes/dynamic-provisioning | ||
- https://github.com/kubernetes-sigs/aws-ebs-csi-driver/tree/master/deploy/kubernetes/overlays/stable | ||
- https://github.com/kubernetes-sigs/aws-ebs-csi-driver | ||
- **Legacy:** | ||
- https://kubernetes.io/docs/concepts/storage/storage-classes/#aws-ebs | ||
- https://docs.aws.amazon.com/eks/latest/userguide/storage-classes.html |
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
...ticBlockStore/04-02-SC-PVC-ConfigMap-MySQL/kube-manifests/03-UserManagement-ConfigMap.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: usermanagement-dbcreation-script | ||
data: | ||
mysql_usermgmt.sql: |- | ||
DROP DATABASE IF EXISTS usermgmt; | ||
CREATE DATABASE usermgmt; |
37 changes: 37 additions & 0 deletions
37
...EBS-ElasticBlockStore/04-02-SC-PVC-ConfigMap-MySQL/kube-manifests/04-mysql-deployment.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: mysql | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: mysql | ||
strategy: | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
app: mysql | ||
spec: | ||
containers: | ||
- name: mysql | ||
image: mysql:5.6 | ||
env: | ||
- name: MYSQL_ROOT_PASSWORD | ||
value: dbpassword11 | ||
ports: | ||
- containerPort: 3306 | ||
name: mysql | ||
volumeMounts: | ||
- name: mysql-persistent-storage | ||
mountPath: /var/lib/mysql | ||
- name: usermanagement-dbcreation-script | ||
mountPath: /docker-entrypoint-initdb.d | ||
volumes: | ||
- name: mysql-persistent-storage | ||
persistentVolumeClaim: | ||
claimName: ebs-mysql-pv-claim | ||
- name: usermanagement-dbcreation-script | ||
configMap: | ||
name: usermanagement-dbcreation-script |
10 changes: 10 additions & 0 deletions
10
...sticBlockStore/04-02-SC-PVC-ConfigMap-MySQL/kube-manifests/05-mysql-clusterip-service.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: mysql | ||
spec: | ||
selector: | ||
app: mysql | ||
ports: | ||
- port: 3306 | ||
clusterIP: None |
74 changes: 74 additions & 0 deletions
74
04-EKS-Storage-with-EBS-ElasticBlockStore/04-03-UserMgmtService/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Kubernetes Storage - Storage Classes, Persistent Volume Claims | ||
|
||
|
||
## Step-01: Introduction | ||
| Kubernetes Object | YAML File | | ||
| ------------- | ------------- | | ||
| Storage Class | 01-storage-class.yml | | ||
| Persistent Volume Claim | 02-persistent-volume-claim.yml | | ||
| User Management Config Map | 03-UserManagement-ConfigMap.yml | | ||
| MySQL Deployment | 04-mysql-deployment.yml | | ||
| MySQL ClusterIp | 05-mysql-clusterip-service.yml | | ||
| User Management Microservice Deployment | 06-UserManagementMicroservice-Deployment.yml | | ||
| User Management NodePort Service | 07-UserManagement-Service.yml | | ||
|
||
## Step-02: Create Storage Class and Persistent Volume Claim | ||
``` | ||
# Create EBS Storage Class | ||
kubectl apply -f kube-manifests/V1/01-storage-class.yml | ||
kubectl get sc | ||
# Create EBS Persistent Volume Claim | ||
kubectl apply -f kube-manifests/V1/02-persistent-volume-claim.yml | ||
kubectl get pvc | ||
``` | ||
- **Dynamic Volume Provisioning:** https://kubernetes.io/docs/concepts/storage/dynamic-provisioning/ | ||
## Step-03: Create ConfigMap for User Management Service | ||
``` | ||
kubectl apply -f kube-manifests/V1/03-UserManagement-ConfigMap.yml | ||
``` | ||
## Step-04: Create MySQL Deployment & Service | ||
``` | ||
kubectl apply -f kube-manifests/V1/04-mysql-deployment.yml | ||
kubectl apply -f kube-manifests/V1/05-mysql-clusterip-service.yml | ||
kubectl get pods -l app=mysql | ||
kubectl run -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql -ppassword | ||
``` | ||
|
||
## Step-05: Create User Management Deployment & Service | ||
- **Environment Variables of User Management Microservice** | ||
| First Header | Second Header | | ||
| ------------- | ------------- | | ||
| DB_HOSTNAME | mysql | | ||
| DB_PORT | 3306 | | ||
| DB_NAME | usermgmt | | ||
| DB_USERNAME | root | | ||
| DB_PASSWORD | dbpassword11 | | ||
|
||
``` | ||
kubectl apply -f kube-manifests/V1/06-UserManagementMicroservice-Deployment-Service.yml | ||
kubectl apply -f kube-manifests/V1/07-UserManagement-Service.yml | ||
``` | ||
- **Access Application** | ||
``` | ||
http://<EKS-WorkerNode-Public-IP>:31231/usermgmt/health-status | ||
``` | ||
|
||
|
||
|
||
- Recreate the Application | ||
``` | ||
kubectl apply -f kube-manifests/V5-Resizing-EBS/ | ||
``` | ||
|
||
|
||
## References: | ||
- https://github.com/kubernetes-sigs/aws-ebs-csi-driver/tree/master/deploy/kubernetes/overlays/stable | ||
- https://docs.aws.amazon.com/eks/latest/userguide/ebs-csi.html | ||
- https://github.com/kubernetes-sigs/aws-ebs-csi-driver | ||
- https://github.com/kubernetes-sigs/aws-ebs-csi-driver/tree/master/examples/kubernetes/dynamic-provisioning | ||
- https://github.com/kubernetes-sigs/aws-ebs-csi-driver/tree/master/deploy/kubernetes/overlays/stable | ||
- https://github.com/kubernetes-sigs/aws-ebs-csi-driver | ||
- **Legacy:** | ||
- https://kubernetes.io/docs/concepts/storage/storage-classes/#aws-ebs | ||
- https://docs.aws.amazon.com/eks/latest/userguide/storage-classes.html |
39 changes: 39 additions & 0 deletions
39
...04-03-UserMgmtService/kube-manifests/06-UserManagementMicroservice-Deployment-Service.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: usermgmt-microservice | ||
labels: | ||
app: usermgmt-restapp | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: usermgmt-restapp | ||
template: | ||
metadata: | ||
labels: | ||
app: usermgmt-restapp | ||
spec: | ||
containers: | ||
- name: usermgmt-restapp | ||
image: stacksimplify/kube-usermanagement-microservice:1.0.0 | ||
resources: | ||
requests: | ||
memory: "128Mi" | ||
cpu: "500m" | ||
limits: | ||
memory: "500Mi" | ||
cpu: "1000m" | ||
ports: | ||
- containerPort: 8095 | ||
env: | ||
- name: DB_HOSTNAME | ||
value: "mysql" | ||
- name: DB_PORT | ||
value: "3306" | ||
- name: DB_NAME | ||
value: "usermgmt" | ||
- name: DB_USERNAME | ||
value: "root" | ||
- name: DB_PASSWORD | ||
value: "dbpassword11" |
14 changes: 14 additions & 0 deletions
14
...-EBS-ElasticBlockStore/04-03-UserMgmtService/kube-manifests/07-UserManagement-Service.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: usermgmt-restapp-service | ||
labels: | ||
app: usermgmt-restapp | ||
spec: | ||
type: NodePort | ||
selector: | ||
app: usermgmt-restapp | ||
ports: | ||
- port: 8095 | ||
targetPort: 8095 | ||
nodePort: 31231 |
Oops, something went wrong.