This docker machine creates a Kubernetes cluster on AWS using Kops, kubectl and the AWS Cli.
195
With docker run we'll provision both a simple .k8s.local and a production grade Kubernetes cluster. The [Dockeerfile] takes care of installing kops, kubectl and the AWS Cli.
.k8s.local Kubernetes clustergit clone https://github.com/devops4me/docker-kopscd docker-kopsk8s-admin-key.pubAmazonEC2FullAccess
AmazonRoute53FullAccess
AmazonS3FullAccess
IAMFullAccess
AmazonVPCFullAccess
.k8s.local Kubernetes ClusterRun the docker build after placing the RSA public key (2048 or 4096 bits) in the k8s-admin-key.pub file. Next set the S3 bucket name, the cluster name, the default region, IAM user keys and the availability zones. Then execute the docker run statement to create the kubernetes cluster.
docker build --no-cache -t img.kops .
docker run --interactive \
--tty \
--rm \
--name vm.kops \
--env KOPS_STATE_STORE=s3://kops.kubernetes.cluster.state \
--env KOPS_CLUSTER_NAME=lab.dublin.k8s.local \
--env NAME=lab.dublin.k8s.local \
--env AWS_DEFAULT_REGION=`safe print region.key` \
--env AWS_ACCESS_KEY_ID=`safe print @access.key` \
--env AWS_SECRET_ACCESS_KEY=`safe print @secret.key` \
-v $PWD:/root \
img.kops kops create cluster --zones "eu-west-1a,eu-west-1b,eu-west-1c" --master-count 3 --master-size=t2.micro --node-count 3 --node-size=t2.micro --yes
Find the IP address or public DNS name of any master node and ssh into it like so.
ssh admin@<<ec2-public-dns-name>> -i /path/to/private-key.pem
If you run kubectl too early you'll get a Unable to connect to the server: EOF error message.
docker run --rm --volume $PWD:/root img.kops kubectl get nodes -o wide
We can delete the entire VPC wrapped Kubernetes cluster by specifying the cluster name, state s3 bucket store name and IAM user's region and access keys.
docker run --interactive \
--tty \
--rm \
--name vm.kops \
--env KOPS_STATE_STORE=s3://kops.kubernetes.cluster.state \
--env KOPS_CLUSTER_NAME=lab.dublin.k8s.local \
--env NAME=lab.dublin.k8s.local \
--env AWS_DEFAULT_REGION=`safe print region.key` \
--env AWS_ACCESS_KEY_ID=`safe print @access.key` \
--env AWS_SECRET_ACCESS_KEY=`safe print @secret.key` \
img.kops kops delete cluster --yes
git clone https://github.com/devops4me/docker-kopscd docker-kopsdig NS devopswiki.co.uk to check access to the domain namedig NS devopswiki.co.uk
safe login <<book.name>>
safe open kubernetes lab.dublin
docker build -t img.kops .
docker build --no-cache -t img.kops .
docker run --interactive \
--tty \
--rm \
--name vm.kops \
--env KOPS_STATE_STORE=s3://kops.kubernetes.cluster.state \
--env KOPS_CLUSTER_NAME=lab.dublin.k8s.local \
--env NAME=lab.dublin.k8s.local \
--env AWS_DEFAULT_REGION=`safe print region.key` \
--env AWS_ACCESS_KEY_ID=`safe print @access.key` \
--env AWS_SECRET_ACCESS_KEY=`safe print @secret.key` \
img.kops
Content type
Image
Digest
Size
252.8 MB
Last updated
over 6 years ago
docker pull devops4me/kops