Create micro service by IBM Cloud Kubernetes Services
[root@kube online_banking_ui]# cat Dockerfile
FROM mhart/alpine-node:11 AS builder
WORKDIR /app
COPY . .
RUN npm install
RUN npm run-script build
FROM mhart/alpine-node
RUN yarn global add serve
WORKDIR /app
COPY --from=builder /app/build .
CMD ["serve", "-p", "80", "-s", "."]
# Build Images in IBM Cloud Register
[root@kube online_banking_ui]# ibmcloud cr build -t us.icr.io/ahmed-workshop/onlineing-banking-ui .
latest: digest: sha256:0740ebd71c52e92550696aefc5741d85414c865df77913543885c98153683907 size: 1367
OK
# List images:
[root@kube online_banking_ui]# ibmcloud cr images
Listing images...
Repository Tag Digest Namespace Created Size Security status
us.icr.io/ahmed-workshop/onlineing-banking-ui latest 0740ebd71c52 ahmed-workshop 21 minutes ago 44 MB No Issues
OK
# Create Deployment from Images:
[root@kube loan_service]# kubectl create deployment online-banking-ui --image=us.icr.io/ahmed-workshop/onlineing-banking-ui
deployment.apps/online-banking-ui created
[root@kube loan_service]# kubectl get pods
NAME READY STATUS RESTARTS AGE
online-banking-ui-767795696-m59g9 1/1 Running 0 24s
# Create expose for pod using port 80:
[root@kube loan_service]# kubectl expose deployment online-banking-ui --type=NodePort --port=80
service/online-banking-ui exposed
[root@kube loan_service]# kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 172.21.0.1 <none> 443/TCP 2d22h
online-banking-ui NodePort 172.21.23.53 <none> 80:31845/TCP 2m15s
# URL http://Public-IP:31845
================================================================Good Luck
https://www.linkedin.com/in/ahmedms/
Comments
Post a Comment