AWS Cloud

[Cloud] Deploy Application in EKS

트리스탄1234 2023. 5. 7. 19:17
728x90
반응형

Hello neighbors ^.^
good morning....

Today, I amgoing to post how to deploy application in amazaon EKS 

The figure below is a diagram for this posting.

After performing this procedure, 3 front-end containers and 3 back-end containers will be running.

  1. In the Baston host, use the cd command to move to the home directory.
sh-4.2$ cd
sh-4.2$ pwd
/home/ssm-user
sh-4.2$

2. Copy the application you want to deploy from Amazon S3 using the command below.

excute command

aws s3 cp s3://aws-tc-largeobjects/ILT-TF-200-COREKS-10-EN/lab-1/ecsdemo-crystal/ ~/ecsdemo-crystal/ --recursive ==> Download crystal program

aws s3 cp s3://aws-tc-largeobjects/ILT-TF-200-COREKS-10-EN/lab-1/ecsdemo-frontend/ ~/ecsdemo-frontend/ --recursive ==> Download frontend application

aws s3 cp s3://aws-tc-largeobjects/ILT-TF-200-COREKS-10-EN/lab-1/ecsdemo-nodejs/ ~/ecsdemo-nodejs/ --recursive ==> Download nodejs Application

반응형

excute result

download: s3://aws-tc-largeobjects/ILT-TF-200-COREKS-10-EN/lab-1/ecsdemo-crystal/.git/logs/refs/remotes/origin/HEAD to ecsdemo-crystal/.git/logs/refs/remotes/origin/HEAD
download: s3://aws-tc-largeobjects/ILT-TF-200-COREKS-10-EN/lab-1/ecsdemo-crystal/src/server.cr to ecsdemo-crystal/src/server.cr
download: s3://aws-tc-largeobjects/ILT-TF-200-COREKS-10-EN/lab-1/ecsdemo-crystal/startup-cdk.sh to ecsdemo-crystal/startup-cdk.sh
download: s3://aws-tc-largeobjects/ILT-TF-200-COREKS-10-EN/lab-1/ecsdemo-crystal/cdk/app.py to ecsdemo-crystal/cdk/app.py
download: s3://aws-tc-largeobjects/ILT-TF-200-COREKS-10-EN/lab-1/ecsdemo-crystal/startup.sh to ecsdemo-crystal/startup.sh
download: s3://aws-tc-largeobjects/ILT-TF-200-COREKS-10-EN/lab-1/ecsdemo-crystal/kubernetes/deployment.yaml to ecsdemo-crystal/kubernetes/deployment.yaml
download: s3://aws-tc-largeobjects/ILT-TF-200-COREKS-10-EN/lab-1/ecsdemo-crystal/kubernetes/service.yaml to ecsdemo-crystal/kubernetes/service.yaml
download: s3://aws-tc-largeobjects/ILT-TF-200-COREKS-10-EN/lab-1/ecsdemo-crystal/src/default_ip/default_ip.cr to ecsdemo-crystal/src/default_ip/default_ip.cr

3.Use the command below to move to the downloaded folder for deploying Node js, the backend application

sh-4.2$ cd ~/ecsdemo-nodejs
sh-4.2$ pwd
/home/ssm-user/ecsdemo-nodejs

4.Deploy Nodejs using the deploymentyaml file in that folder

sh-4.2$ kubectl apply -f kubernetes/deployment.yaml
deployment.apps/ecsdemo-nodejs created

The content of the deployed Deployment.yaml file is as follows.

apiVersion: apps/v1
kind: Deployment
metadata:
name: ecsdemo-nodejs
labels:
app: ecsdemo-nodejs
namespace: default
spec:
replicas: 1 
selector:
matchLabels:
app: ecsdemo-nodejs
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: ecsdemo-nodejs
spec: 
containers:
- image: brentley/ecsdemo-nodejs:latest
imagePullPolicy: Always
name: ecsdemo-nodejs
ports:
- containerPort: 3000
protocol: TCP

5.Now deploy Service object for Nodejs Pod.

sh-4.2$ kubectl apply -f kubernetes/service.yaml
service/ecsdemo-nodejs created

The content of the deployed service.yaml file is as follows:

The value defined in the selector part and the value defined in the label in the above depployment must be the same... The deployed Service object operates as a Service object for the Pod deployed above

apiVersion: v1
kind: Service
metadata:
name: ecsdemo-nodejs
spec:
selector:
app: ecsdemo-nodejs
ports:
- protocol: TCP
port: 80
targetPort: 3000

 

6.Use the command below to check if the distribution was successful

sh-4.2$ kubectl get deployment ecsdemo-nodejs
NAME READY UP-TO-DATE AVAILABLE AGE
ecsdemo-nodejs 1/1 1 1 9m16s
sh-4.2$

7. Now move to the cloned directory to deploy the crystal application.

sh-4.2$ cd ~/ecsdemo-crystal
sh-4.2$ pwd
/home/ssm-user/ecsdemo-crystal

8. Deploy the pod for the crysatal application using the command below.

sh-4.2$ kubectl apply -f kubernetes/deployment.yaml
deployment.apps/ecsdemo-crystal created

9. Use the command below to check the status of the deployed pod.

h-4.2$ kubectl get deployment ecsdemo-crystal
NAME READY UP-TO-DATE AVAILABLE AGE
ecsdemo-crystal 1/1 1 1 44s

10. The content of the deployment.yaml file deployed above is as follows.

apiVersion: apps/v1
kind: Deployment
metadata:
name: ecsdemo-crystal
labels:
app: ecsdemo-crystal
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: ecsdemo-crystal
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: ecsdemo-crystal
spec:
containers:
- image: brentley/ecsdemo-crystal:latest
imagePullPolicy: Always
name: ecsdemo-crystal
ports:
- containerPort: 3000
protocol: TCP

11. Now move the directory using the command below for the frontend application

sh-4.2$ cd ~/ecsdemo-frontend
sh-4.2$ pwd
/home/ssm-user/ecsdemo-frontend

12. Now deploy the deployment object using the command below for the frontend.

h-4.2$ kubectl apply -f kubernetes/deployment.yaml
deployment.apps/ecsdemo-frontend created

The content of the distributed file is as follows

apiVersion: apps/v1
kind: Deployment
metadata:
name: ecsdemo-frontend
labels:
app: ecsdemo-frontend
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: ecsdemo-frontend
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: ecsdemo-frontend
spec:
containers:
- image: brentley/ecsdemo-frontend:latest
imagePullPolicy: Always
name: ecsdemo-frontend
ports:
- containerPort: 3000
protocol: TCP
env:
- name: CRYSTAL_URL
- name: NODEJS_URL

13. Now deploy the service object for the frontend using the command below.

sh-4.2$ kubectl apply -f kubernetes/service.yaml
service/ecsdemo-frontend created

The file content of the service object is as follows. The type of service object is set to load balancer.

apiVersion: v1
kind: Service
metadata:
name: ecsdemo-frontend
spec:
selector:
app: ecsdemo-frontend
type: LoadBalancer
ports:
- protocol: TCP
port: 80
targetPort: 3000

14. Now, check if the distribution is successful by using the command below..

sh-4.2$ kubectl get deployment ecsdemo-frontend
NAME READY UP-TO-DATE AVAILABLE AGE
ecsdemo-frontend 1/1 1 1 4m43s

15. Use the command below to check the objects in the deployment deployed in the default namespace

sh-4.2$ kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
ecsdemo-crystal 1/1 1 1 10m
ecsdemo-frontend 1/1 1 1 6m10s
ecsdemo-nodejs 1/1 1 1 23m

16. Check the details of the service object of the frontend with the command below..

h-4.2$ kubectl get service ecsdemo-frontend -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
ecsdemo-frontend LoadBalancer 10.100.224.148 a4c8739fa3eea4039b11b7ea641306cc-655281564.ap-southeast-2.elb.amazonaws.com 80:32084/TCP 5m32s app=ecsdemo-frontend

Copy the External-IP section of the displayed output.

17. Now, open a new web browser, enter https://, copy the extenal ip information copied above to the browser and press enter.

Then you can see that the web page of the application opens

18 Use the command below to retrieve information about Pods deployed in the default namespace.

sh-4.2$ kubectl get pods -n default
NAME READY STATUS RESTARTS AGE
ecsdemo-crystal-69bd6dbf88-wjbmc 1/1 Running 0 31m
ecsdemo-frontend-5744c78747-6h676 1/1 Running 0 26m
ecsdemo-nodejs-6f79d847d9-xlsd8 1/1 Running 0 44m
sh-4.2$

19 Use the command below to save the name of the pod you want to look at details into a variable.

sh-4.2$ export MY_POD_NAME=$(kubectl get pods -n default -o jsonpath='{.items[0].metadata.name}')

20 Use the saved Pod variable to look at the details of the Pod.

sh-4.2$ kubectl -n default describe pod $MY_POD_NAME
Name: ecsdemo-crystal-69bd6dbf88-wjbmc
Namespace: default
Priority: 0
Node: ip-192-168-88-46.ap-southeast-2.compute.internal/192.168.88.46
Start Time: Mon, 01 May 2023 06:29:44 +0000
Labels: app=ecsdemo-crystal
pod-template-hash=69bd6dbf88
Annotations: kubernetes.io/psp: eks.privileged
Status: Running
IP: 192.168.95.171
IPs:
IP: 192.168.95.171
Controlled By: ReplicaSet/ecsdemo-crystal-69bd6dbf88
Containers:
ecsdemo-crystal:
Container ID: docker://eaafaa0c823192e110a461ba6787af99462b9b5181bc6245460627c765edaf5f
Image: brentley/ecsdemo-crystal:latest
Image ID: docker-pullable://brentley/ecsdemo-crystal@sha256:4e2726f8fcf148f8978c34e88c9f7468cbc39815daccf6803daa7c9bf44353db
Port: 3000/TCP
Host Port: 0/TCP
State: Running
Started: Mon, 01 May 2023 06:29:54 +0000
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-btz8x (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-btz8x:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 32m default-scheduler Successfully assigned default/ecsdemo-crystal-69bd6dbf88-wjbmc to ip-192-168-88-46.ap-southeast-2.compute.internal
Normal Pulling 32m kubelet Pulling image "brentley/ecsdemo-crystal:latest"
Normal Pulled 32m kubelet Successfully pulled image "brentley/ecsdemo-crystal:latest" in 8.556365127s (8.556371021s including waiting)
Normal Created 32m kubelet Created container ecsdemo-crystal
Normal Started 32m kubelet Started container ecsdemo-crystal

Well, that's it for today ^.^
I hope you have a happy day today.

 

"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."

728x90
반응형