Skip to content

Kubernetes Lab

Install Tools

Clone Lab Repo

  • git clone

Setup Kubernetes Dashboard

  • Find create-service-account.yaml and cluster-role-binding.yaml in csye7374-labs-spring2019/kubernetes/dashboard directory.
  • Execute kubectl apply -f create-service-account.yaml and kubectl apply -f cluster-role-binding.yaml.
  • Deploy dashboard with command kubectl apply -f
  • Get dashboard login token using the command kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}').
  • Dashboard can now be accessed locally via kubectl proxy at http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/.

AWS Container Registry IAM Setup

aws iam attach-group-policy --policy-arn arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess  --group-name kops

Create ECR Repository Using AWS CLI

aws ecr create-repository --repository-name csye7374

Deploying App to Kubernetes Cluster

  • A simple Node.js application is located in csye7374-labs-spring2019/webapp directory.
  • A Docker file to build the image is in csye7374-labs-spring2019/webapp directory.

Build & Push Docker Container Image to Amazon ECR

Retrieve the login command to use to authenticate your Docker client to your registry

aws ecr get-login --no-include-email --region us-east-1

Build Docker Image

docker build -t csye7374 .

Tag Docker Image

docker tag csye7374:latest <AWS_ACCOUNT_ID>

Push Docker Image

docker push <AWS_ACCOUNT_ID>

Run Application

Create Deployment

  • Pod deployment file can be found in csye7374-labs-spring2019/kubernetes/app directory.
  • Create deployment using kubectl apply -f csye7374-pod.yaml

Access Application

Make REST calls to your application by creating a proxy

kubectl port-forward csye7374 8888:8080
curl http://localhost:8888