Docker : Kubernetes Minikube install on AWS EC2
Create an EC2 instance with Ubuntu 18 ami-085925f297f89fce1 (64-bit x86) - initially, t3.micro (2 vCPU, 1GB Memory) but we may need to upgrade depending on app requirements).
SSH into the instance:
$ ssh -i my.pem ubuntu@3.83.123.125 Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-1065-aws x86_64) ... ubuntu@ip-172-31-50-87:~$
The Kubernetes command-line tool, kubectl
, allows us to run commands against Kubernetes clusters to deploy applications,
inspect and manage cluster resources, and view logs.
We can follow the instructions from Install and Set Up kubectl. We'll install kubectl binary with curl:
- Download the latest release with the command:
ubuntu@ip-172-31-50-87:~$ curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
- Make the kubectl binary executable.
ubuntu@ip-172-31-50-87:~$ chmod +x ./kubectl
- Move the binary in to your PATH.
ubuntu@ip-172-31-50-87:~$ sudo mv ./kubectl /usr/local/bin/kubectl
- Test to ensure the version you installed is up-to-date:
ubuntu@ip-172-31-50-87:~$ kubectl version --client Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Docker install:
ubuntu@ip-172-31-50-87:~$ sudo apt-get update -y && sudo apt-get install -y docker.io ubuntu@ip-172-31-50-87:~$ sudo docker version Client: Version: 19.03.6 API version: 1.40 Go version: go1.12.17 Git commit: 369ce74a3c Built: Fri Feb 28 23:45:43 2020 OS/Arch: linux/amd64 Experimental: false Server: Engine: Version: 19.03.6 API version: 1.40 (minimum version 1.12) Go version: go1.12.17 Git commit: 369ce74a3c Built: Wed Feb 19 01:06:16 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.3.3-0ubuntu1~18.04.2 GitCommit: runc: Version: spec: 1.0.1-dev GitCommit: docker-init: Version: 0.18.0 GitCommit:
Minikube install:
ubuntu@ip-172-31-50-87:~$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \ && chmod +x minikube \ && sudo mv minikube /usr/local/bin/ ubuntu@ip-172-31-50-87:~$ minikube version minikube version: v1.9.2 commit: 93af9c1e43cab9618e301bc9fa720c63d5efa393
Minikube supports a --driver=none
option that runs the Kubernetes components on the host and not in a VM.
For more info about the "none", please check https://minikube.sigs.k8s.io/docs/drivers/none/.
ubuntu@ip-172-31-50-87:~$ sudo -i root@ip-172-31-50-87:~# minikube start --driver=none minikube v1.9.2 on Ubuntu 18.04 Using the none driver based on user configuration Sorry, Kubernetes v1.18.0 requires conntrack to be installed in root's path
Install the conntrack:
root@ip-172-31-50-87:~# apt install conntrack Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: conntrack 0 upgraded, 1 newly installed, 0 to remove and 27 not upgraded. Need to get 30.6 kB of archives. After this operation, 104 kB of additional disk space will be used. Get:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic/main amd64 conntrack amd64 1:1.4.4+snapshot20161117-6ubuntu2 [30.6 kB] Fetched 30.6 kB in 0s (0 B/s) Selecting previously unselected package conntrack. (Reading database ... 56919 files and directories currently installed.) Preparing to unpack .../conntrack_1%3a1.4.4+snapshot20161117-6ubuntu2_amd64.deb ... Unpacking conntrack (1:1.4.4+snapshot20161117-6ubuntu2) ... Setting up conntrack (1:1.4.4+snapshot20161117-6ubuntu2) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Then, try to start minikube again:
root@ip-172-31-50-87:~# minikube start --driver=none minikube v1.9.2 on Ubuntu 18.04 Using the none driver based on user configuration Starting control plane node in cluster minikube Running on localhost (CPUs=2, Memory=957MB, Disk=7876MB) ... OS release is Ubuntu 18.04.4 LTS Preparing Kubernetes v1.18.0 on Docker 19.03.6 ... kubelet.resolv-conf=/run/systemd/resolve/resolv.conf > kubelet.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s > kubectl.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s > kubeadm.sha256: 65 B / 65 B [--------------------------] 100.00% ? p/s 0s > kubectl: 41.98 MiB / 41.98 MiB [-----------------------] 100.00% ? p/s 0s > kubeadm: 37.96 MiB / 37.96 MiB [--------------] 100.00% 138.04 MiB p/s 1s > kubelet: 108.01 MiB / 108.01 MiB [------------] 100.00% 174.05 MiB p/s 1s Enabling addons: default-storageclass, storage-provisioner Configuring local host environment ... The 'none' driver is designed for experts who need to integrate with an existing VM Most users should use the newer 'docker' driver instead, which does not require root! For more information, see: https://minikube.sigs.k8s.io/docs/reference/drivers/none/ kubectl and minikube configuration will be stored in /home/ubuntu To use kubectl or minikube commands as your own user, you may need to relocate them. For example, to overwrite your own settings, run: sudo mv /home/ubuntu/.kube /home/ubuntu/.minikube $HOME sudo chown -R $USER $HOME/.kube $HOME/.minikube This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true Done! kubectl is now configured to use "minikube"
Check the status of the minikube:
root@ip-172-31-50-87:~# minikube status host: Running kubelet: Running apiserver: Running kubeconfig: Configured
Check the minikube using kubectl
:
root@ip-172-31-50-87:~# kubectl get pods No resources found in default namespace. root@ip-172-31-50-87:~# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 66s
Use the kubectl create
command to create a Deployment that manages a Pod.
The Pod runs a Container based on the provided Docker image:
root@ip-172-31-50-87:~# kubectl create deployment hello-node --image=k8s.gcr.io/echoserver:1.4 deployment.apps/hello-node created
By default, the Pod is only accessible by its internal IP address within the Kubernetes cluster.
To make the hello-node Container accessible from outside the Kubernetes virtual network, we have to expose the Pod as a Kubernetes Service.
So, let's expose the Pod to the public using the kubectl expose
command:
root@ip-172-31-50-87:~# kubectl expose deployment hello-node --type=NodePort --port=8080 service/hello-node exposed root@ip-172-31-50-87:~# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-node NodePort 10.110.178.19 <none> 8080:32256/TCP 18s kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 18m
We need to set Security group inbound for the ip range of NodePort:
Let's check if it works. On our local machine, public_ip:NODE_PORT:
$ curl -v 3.83.123.125:32256 * Rebuilt URL to: 3.83.123.125:32256/ * Trying 3.83.123.125... * TCP_NODELAY set * Connected to 3.83.123.125 (3.83.123.125) port 32256 (#0) > GET / HTTP/1.1 > Host: 3.83.123.125:32256 > User-Agent: curl/7.54.0 > Accept: */* > < HTTP/1.1 200 OK < Server: nginx/1.10.0 < Date: Mon, 11 May 2020 19:00:33 GMT < Content-Type: text/plain < Transfer-Encoding: chunked < Connection: keep-alive < CLIENT VALUES: client_address=172.17.0.1 command=GET real path=/ query=nil request_version=1.1 request_uri=http://3.83.123.125:8080/ SERVER VALUES: server_version=nginx: 1.10.0 - lua: 10001 HEADERS RECEIVED: accept=*/* host=3.83.123.125:32256 user-agent=curl/7.54.0 BODY: * Connection #0 to host 3.83.123.125 left intact
Note that our hello-node port 8080 is exposed to public on port 32256.
Note also that we can access it within the cluster via $(minikube ip):$NODE_PORT:
:
root@ip-172-31-50-87:~# minikube ip 172.31.50.87 root@ip-172-31-50-87:~# curl 172.31.50.87:32256 CLIENT VALUES: client_address=172.17.0.1 command=GET real path=/ query=nil request_version=1.1 request_uri=http://172.31.50.87:8080/ SERVER VALUES: server_version=nginx: 1.10.0 - lua: 10001 HEADERS RECEIVED: accept=*/* host=172.31.50.87:32256 user-agent=curl/7.58.0 BODY: -no body in request-
Note that we can also do:
$ minikube service hello-node
It will open up a browser for us.
Let's delete the service and the pod (deployment):
root@ip-172-31-50-87:~# kubectl get pods NAME READY STATUS RESTARTS AGE hello-node-7bf657c596-h9v9m 1/1 Running 0 1h31m root@ip-172-31-50-87:~# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-node NodePort 10.110.178.19 <none> 8080:32256/TCP 1h21m kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 1h39m root@ip-172-31-50-87:~# kubectl get deployments NAME READY UP-TO-DATE AVAILABLE AGE hello-node 1/1 1 1 1h31m root@ip-172-31-50-87:~# kubectl delete svc hello-node service "hello-node" deleted root@ip-172-31-50-87:~# kubectl delete deployment hello-node deployment.apps "hello-node" deleted root@ip-172-31-50-87:~# kubectl get pods No resources found in default namespace. root@ip-172-31-50-87:~# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1443/TCP 1h43m root@ip-172-31-50-87:~# kubectl get deployments No resources found in default namespace.
And then, we may want to stop our minikube:
root@ip-172-31-50-87:~# minikube stop Stopping "minikube" in none ... Node "" stopped.
Docker & K8s
- Docker install on Amazon Linux AMI
- Docker install on EC2 Ubuntu 14.04
- Docker container vs Virtual Machine
- Docker install on Ubuntu 14.04
- Docker Hello World Application
- Nginx image - share/copy files, Dockerfile
- Working with Docker images : brief introduction
- Docker image and container via docker commands (search, pull, run, ps, restart, attach, and rm)
- More on docker run command (docker run -it, docker run --rm, etc.)
- Docker Networks - Bridge Driver Network
- Docker Persistent Storage
- File sharing between host and container (docker run -d -p -v)
- Linking containers and volume for datastore
- Dockerfile - Build Docker images automatically I - FROM, MAINTAINER, and build context
- Dockerfile - Build Docker images automatically II - revisiting FROM, MAINTAINER, build context, and caching
- Dockerfile - Build Docker images automatically III - RUN
- Dockerfile - Build Docker images automatically IV - CMD
- Dockerfile - Build Docker images automatically V - WORKDIR, ENV, ADD, and ENTRYPOINT
- Docker - Apache Tomcat
- Docker - NodeJS
- Docker - NodeJS with hostname
- Docker Compose - NodeJS with MongoDB
- Docker - Prometheus and Grafana with Docker-compose
- Docker - StatsD/Graphite/Grafana
- Docker - Deploying a Java EE JBoss/WildFly Application on AWS Elastic Beanstalk Using Docker Containers
- Docker : NodeJS with GCP Kubernetes Engine
- Docker : Jenkins Multibranch Pipeline with Jenkinsfile and Github
- Docker : Jenkins Master and Slave
- Docker - ELK : ElasticSearch, Logstash, and Kibana
- Docker - ELK 7.6 : Elasticsearch on Centos 7
- Docker - ELK 7.6 : Filebeat on Centos 7
- Docker - ELK 7.6 : Logstash on Centos 7
- Docker - ELK 7.6 : Kibana on Centos 7
- Docker - ELK 7.6 : Elastic Stack with Docker Compose
- Docker - Deploy Elastic Cloud on Kubernetes (ECK) via Elasticsearch operator on minikube
- Docker - Deploy Elastic Stack via Helm on minikube
- Docker Compose - A gentle introduction with WordPress
- Docker Compose - MySQL
- MEAN Stack app on Docker containers : micro services
- MEAN Stack app on Docker containers : micro services via docker-compose
- Docker Compose - Hashicorp's Vault and Consul Part A (install vault, unsealing, static secrets, and policies)
- Docker Compose - Hashicorp's Vault and Consul Part B (EaaS, dynamic secrets, leases, and revocation)
- Docker Compose - Hashicorp's Vault and Consul Part C (Consul)
- Docker Compose with two containers - Flask REST API service container and an Apache server container
- Docker compose : Nginx reverse proxy with multiple containers
- Docker & Kubernetes : Envoy - Getting started
- Docker & Kubernetes : Envoy - Front Proxy
- Docker & Kubernetes : Ambassador - Envoy API Gateway on Kubernetes
- Docker Packer
- Docker Cheat Sheet
- Docker Q & A #1
- Kubernetes Q & A - Part I
- Kubernetes Q & A - Part II
- Docker - Run a React app in a docker
- Docker - Run a React app in a docker II (snapshot app with nginx)
- Docker - NodeJS and MySQL app with React in a docker
- Docker - Step by Step NodeJS and MySQL app with React - I
- Installing LAMP via puppet on Docker
- Docker install via Puppet
- Nginx Docker install via Ansible
- Apache Hadoop CDH 5.8 Install with QuickStarts Docker
- Docker - Deploying Flask app to ECS
- Docker Compose - Deploying WordPress to AWS
- Docker - WordPress Deploy to ECS with Docker-Compose (ECS-CLI EC2 type)
- Docker - WordPress Deploy to ECS with Docker-Compose (ECS-CLI Fargate type)
- Docker - ECS Fargate
- Docker - AWS ECS service discovery with Flask and Redis
- Docker & Kubernetes : minikube
- Docker & Kubernetes 2 : minikube Django with Postgres - persistent volume
- Docker & Kubernetes 3 : minikube Django with Redis and Celery
- Docker & Kubernetes 4 : Django with RDS via AWS Kops
- Docker & Kubernetes : Kops on AWS
- Docker & Kubernetes : Ingress controller on AWS with Kops
- Docker & Kubernetes : HashiCorp's Vault and Consul on minikube
- Docker & Kubernetes : HashiCorp's Vault and Consul - Auto-unseal using Transit Secrets Engine
- Docker & Kubernetes : Persistent Volumes & Persistent Volumes Claims - hostPath and annotations
- Docker & Kubernetes : Persistent Volumes - Dynamic volume provisioning
- Docker & Kubernetes : DaemonSet
- Docker & Kubernetes : Secrets
- Docker & Kubernetes : kubectl command
- Docker & Kubernetes : Assign a Kubernetes Pod to a particular node in a Kubernetes cluster
- Docker & Kubernetes : Configure a Pod to Use a ConfigMap
- AWS : EKS (Elastic Container Service for Kubernetes)
- Docker & Kubernetes : Run a React app in a minikube
- Docker & Kubernetes : Minikube install on AWS EC2
- Docker & Kubernetes : Cassandra with a StatefulSet
- Docker & Kubernetes : Terraform and AWS EKS
- Docker & Kubernetes : Pods and Service definitions
- Docker & Kubernetes : Service IP and the Service Type
- Docker & Kubernetes : Kubernetes DNS with Pods and Services
- Docker & Kubernetes : Headless service and discovering pods
- Docker & Kubernetes : Scaling and Updating application
- Docker & Kubernetes : Horizontal pod autoscaler on minikubes
- Docker & Kubernetes : From a monolithic app to micro services on GCP Kubernetes
- Docker & Kubernetes : Rolling updates
- Docker & Kubernetes : Deployments to GKE (Rolling update, Canary and Blue-green deployments)
- Docker & Kubernetes : Slack Chat Bot with NodeJS on GCP Kubernetes
- Docker & Kubernetes : Continuous Delivery with Jenkins Multibranch Pipeline for Dev, Canary, and Production Environments on GCP Kubernetes
- Docker & Kubernetes : NodePort vs LoadBalancer vs Ingress
- Docker & Kubernetes : MongoDB / MongoExpress on Minikube
- Docker & Kubernetes : Load Testing with Locust on GCP Kubernetes
- Docker & Kubernetes : MongoDB with StatefulSets on GCP Kubernetes Engine
- Docker & Kubernetes : Nginx Ingress Controller on Minikube
- Docker & Kubernetes : Setting up Ingress with NGINX Controller on Minikube (Mac)
- Docker & Kubernetes : Nginx Ingress Controller for Dashboard service on Minikube
- Docker & Kubernetes : Nginx Ingress Controller on GCP Kubernetes
- Docker & Kubernetes : Kubernetes Ingress with AWS ALB Ingress Controller in EKS
- Docker & Kubernetes : Setting up a private cluster on GCP Kubernetes
- Docker & Kubernetes : Kubernetes Namespaces (default, kube-public, kube-system) and switching namespaces (kubens)
- Docker & Kubernetes : StatefulSets on minikube
- Docker & Kubernetes : RBAC
- Docker & Kubernetes Service Account, RBAC, and IAM
- Docker & Kubernetes - Kubernetes Service Account, RBAC, IAM with EKS ALB, Part 1
- Docker & Kubernetes : Helm Chart
- Docker & Kubernetes : My first Helm deploy
- Docker & Kubernetes : Readiness and Liveness Probes
- Docker & Kubernetes : Helm chart repository with Github pages
- Docker & Kubernetes : Deploying WordPress and MariaDB with Ingress to Minikube using Helm Chart
- Docker & Kubernetes : Deploying WordPress and MariaDB to AWS using Helm 2 Chart
- Docker & Kubernetes : Deploying WordPress and MariaDB to AWS using Helm 3 Chart
- Docker & Kubernetes : Helm Chart for Node/Express and MySQL with Ingress
- Docker & Kubernetes : Deploy Prometheus and Grafana using Helm and Prometheus Operator - Monitoring Kubernetes node resources out of the box
- Docker & Kubernetes : Deploy Prometheus and Grafana using kube-prometheus-stack Helm Chart
- Docker & Kubernetes : Istio (service mesh) sidecar proxy on GCP Kubernetes
- Docker & Kubernetes : Istio on EKS
- Docker & Kubernetes : Istio on Minikube with AWS EC2 for Bookinfo Application
- Docker & Kubernetes : Deploying .NET Core app to Kubernetes Engine and configuring its traffic managed by Istio (Part I)
- Docker & Kubernetes : Deploying .NET Core app to Kubernetes Engine and configuring its traffic managed by Istio (Part II - Prometheus, Grafana, pin a service, split traffic, and inject faults)
- Docker & Kubernetes : Helm Package Manager with MySQL on GCP Kubernetes Engine
- Docker & Kubernetes : Deploying Memcached on Kubernetes Engine
- Docker & Kubernetes : EKS Control Plane (API server) Metrics with Prometheus
- Docker & Kubernetes : Spinnaker on EKS with Halyard
- Docker & Kubernetes : Continuous Delivery Pipelines with Spinnaker and Kubernetes Engine
- Docker & Kubernetes : Multi-node Local Kubernetes cluster : Kubeadm-dind (docker-in-docker)
- Docker & Kubernetes : Multi-node Local Kubernetes cluster : Kubeadm-kind (k8s-in-docker)
- Docker & Kubernetes : nodeSelector, nodeAffinity, taints/tolerations, pod affinity and anti-affinity - Assigning Pods to Nodes
- Docker & Kubernetes : Jenkins-X on EKS
- Docker & Kubernetes : ArgoCD App of Apps with Heml on Kubernetes
- Docker & Kubernetes : ArgoCD on Kubernetes cluster
- Docker & Kubernetes : GitOps with ArgoCD for Continuous Delivery to Kubernetes clusters (minikube) - guestbook
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization