• Stars
    star
    106
  • Rank 325,871 (Top 7 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created almost 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kubernetes setup on Amazon AWS using Kops and Ansible

Kubernetes setup on Amazon AWS using Kops and Ansible

This repository contains tooling for deploying Kubernetes cluster in Amazon AWS using the Kops tool. Kops is a great tool if you want to setup HA cluster and don't require too much flexibility. If you prefer flexibility instead of HA setup you should have a look at another repsoitory where I have Kubernetes setup implemented using Terraform and Kubeadm tool. I have also a special minikube single node installation.

Updates

  • 16.4.2018 Update to Kops 1.9 and Kubernetes 1.9, update addons, remove Storage Class (installed by Kops automatically) and Route53 addon (replaced by ExternalDNS addon)
  • 2.1.2018 Add support for public and private topologies
  • 9.12.2017 Update to Kops 1.8 and Kubernetes 1.8
  • 28.11.2017 Update addon versions
  • 14.10.2017 Update to Kops 1.7.1 which fixes CVE-2017-14491
  • 22.8.2017 Update to Kops 1.7 and Kubernetes 1.7

Installing the cluster

The cluster can be deployed from your local host (tested with MacOS and Linux) by following the steps described below. If you cannot install Ansible, kubectl or kops on your local PC or in case your local PC is running Windows, you can create a EC2 host in Amazon AWS and run the installation from this host.

Install Ansible

Download and install Ansible - you can follow the guide from Ansible website.

Kubectl installation

Install the latest version of kubectl on Linux or MacOS:

ansible-playbook install-kubectl.yaml

You may need either --ask-sudo-pass or ansible_become_pass

Kops installation

Install the latest version of Kops utility on Linux or MacOS:

ansible-playbook install-kops.yaml

You may need either --ask-sudo-pass or ansible_become_pass

AWS Credentials

Export the AWS credentials whih will be used to authenticate with Amazon AWS:

export AWS_ACCESS_KEY_ID="XXX"
export AWS_SECRET_ACCESS_KEY="XXX"

S3 bucket for state store

Create S3 bucket to store where Kops will store its information:

ansible-playbook create-state-store.yaml

The bucket will contain also the access details for the clusters configured with Kops. It should be secured accordingly.

Install Kubernetes cluster

Create the Kubernetes cluster using Kops:

ansible-playbook create.yaml

The main configuration of the cluster is in the variables in group_vars/all/vars.yaml. Following table shows the different options.

Option Explanation Example
cluster_name Name of the cluster which should be created. The name has to end with the domain name of the DNS zone hosted in Route 53. kubernetes.my-cluster.com
state_store Name of the Amazon S3 bucket which should be used as a Kops state store. It should start with s3://. s3://kops-state-store
ssh_public_key Path to the public part of the SSH key, which should be used for the SSH access to the Kubernetes hosts ~/.ssh/id_rsa.pub
aws_region AWS region where the cluster should be installed. eu-west-1
aws_zones List of availability zones in which the cluster should be installed. Must be an odd number (1, 3 or 5) of zones (at least 3 zones are needed for AWS setup accross availability zones). eu-west-1a,eu-west-1b,eu-west-1c
master_zones List of availability zones in which the master nodes should be installed. Must be an odd number (1, 3 or 5) of zones (at least 3 zones are needed for AWS setup accross availability zones). If not specified, aws_zones will be used instead eu-west-1a,eu-west-1b,eu-west-1c
dns_zone Name of the Rote 53 hosted zone. Must be reflected in the cluster name. my-cluster.com
network_cidr A new VPC will be created. It will use the CIDR specified in this option. 172.16.0.0/16
topology Defines whether the cluster should be deployed into private subnet (private - more secure) with bastion host or into public subnet (public - less secure). private
kubernetes_networking Defines which networking plugin should be used in Kubernetes. Tested with Calico only. calico
master_size EC2 size of the nodes used for the Kubernetes masters (and Etcd hosts) m4.large
master_count Number of EC2 master hosts. 3
master_volume_size Size of the master disk volume in GB. 50
master_max_price Optional, max price for master spot instances. 0.05
master_profile Optional, custom master IAM role. arn:aws:iam::1234567890108:instance-profile/kops-custom-master-role
node_size EC2 size of the nodes used as workers. m4.large
node_count Number of EC2 worker hosts (initial count). 6
node_volume_size Size of the node disk volume in GB. 50
node_max_price Optional, max price for node spot instances. 0.05
node_profile Optional, custom node IAM role. arn:aws:iam::1234567890108:instance-profile/kops-custom-node-role
node_autoscaler_min Minimum number of nodes (for the autoscaler). 3
node_autoscaler_max Maximum number of nodes (for the autoscaler). 6
base_image Image used for all the instances kope.io/k8s-1.11-debian-stretch-amd64-hvm-ebs-2018-08-17
kubernetes_version Version of kubernetes which should be used. 1.11
iam.allow_container_registry Optional, boolean to allow read access to Amazon ECR true
iam.legacy Optional, boolean to use the legacy IAM privileges false

Additionally to the Kubernetes cluster it self, an AWS Lambda function may be created which will run periodically to tag all resources creating by Kops and by Kubernetes. To use it, a tag must be specified :

ansible-playbook create.yaml --tags "use_lambda"

It will use following tags:

  • Creator
  • Owner
  • Application
  • CostCenter
  • Product
  • Confidentiality
  • Environment

The tags are configured in also in group_vars/all/vars.yaml using following variables:

Option Explanation Example
tag_creator Value for the Creator tag MyName
tag_owner Value for the Owner tag MyName
tag_application Value for the Application tag MyApp
tag_costcenter Value for the CostCenter tag 1234
tag_product Value for the Product tag MyProduct
tag_confidentiality Value for the Confidentiality tag StrictlyConfidential
tag_environment Value for the Environment tag Development

Additionally to these tags, all resources without the Name tag will be named according to the cluster name (e.g. kubernetes.my-cluster.com-resource)

Install add-ons (optional)

Currently, the supported add-ons are:

  • Kubernetes dashboard
  • Heapster for resource monitoring
  • External DNS
  • Cluster Autoscaler

To install the add-ons run

ansible-playbook addons.yaml

Install ingress (optional)

Ingress can be used route inbound traffic from the outside of the Kubernetes cluster. It can be used for SSL termination, virtual hosts, load balancing etc. For more details about ingress, go to Kubernetes website.

To install ingress controller based on Nginx, run

ansible-playbook ingress.yaml

Install the tagging lambda function (optional)

The AWS Lambda function can be used for tagging of resources created by the Kubernetes installation. To install it run:

ansible-playbook install-lambda.yaml

Updating the cluster

All updates to the running Kubernetes cluster can be done directly using Kops. The Ansible playbooks from this project only simplify the initial setup.

Deleting the cluster

To delete the cluster export the AWS credentials:

export AWS_ACCESS_KEY_ID="XXX"
export AWS_SECRET_ACCESS_KEY="XXX"

And run:

ansible-playbook delete.yaml

Deleting the tagging lambda function

If you installed the AWS Lambda for tagging, you can remove it using this command:

ansible-playbook uninstall-lambda.yaml

## Frequently Asked Questions

How to access Kuberntes Dashboard

The Kubernetes Dashboard addon is by default not exposed to the internet. This is intentional for security reasons (no authentication / authorization) and to save costs for Amazon AWS ELB load balancer.

You can access the dashboard easily fro any computer with installed and configured kubectl:

  1. From command line start kubectl proxy
  2. Go to your browser and open http://127.0.0.1:8001/ui

More Repositories

1

terraform-aws-kubernetes

Terraform module for Kubernetes setup on AWS
HCL
200
star
2

aws-minikube

Single node Kubernetes instance implemented using Terraform and kubeadm
HCL
117
star
3

terraform-aws-minikube

Terraform module for single node Kubernetes instance bootstrapped using kubeadm
HCL
65
star
4

zoo-entrance

Makefile
55
star
5

strimzi-training

Shell
36
star
6

aws-kubernetes

Kubernetes cluster setup in AWS using Terraform and kubeadm
HCL
33
star
7

keycloak-kubernetes

Keycloak deployment into Kubernetes cluster
25
star
8

strimzi-compose-up

Compose file for starting Kafka and Zookeeper using the Strimzi images
21
star
9

kafka-enablement-2020

Materials for Kafka enablement trainings in 2020
Shell
19
star
10

getting-started-with-apache-kafka

Getting Started with Apache Kafka
Java
17
star
11

kafka-topic-view

A simple UI for monitoring Apache Kafka topics and their state.
Go
17
star
12

terraform-aws-vpc

Terraform module for creating s simple Amazon AWS VPC and subnets
HCL
14
star
13

build-your-own-social-media-analytics-with-apache-kafka

Build your own social media analytics with Apache Kafka
Java
14
star
14

kafka-enablement

Enablement training materials
Shell
13
star
15

terraform-aws-tagging-lambda

AWS Lambda function for tagging resources
Python
13
star
16

aws-kubernetes-terraform-ansible

Kubernetes setup in Amazon AWS using Terraform and Ansible
Python
11
star
17

kafka-kubernetes-authenticator

Kafka Kubernetes Authenticator and Authorizer
Java
11
star
18

strimzi-custom-ca-test

Using Strimzi with custom CA
Shell
10
star
19

kekspose

Keksposé: Expose your Kafka cluster outside your Minikube, Kind, or Docker Desktop clusters
Java
10
star
20

milestone-check

Github application which verifies whether a milestone has been set on a PR or not
Java
9
star
21

demo-opa-kafka-authorization

Strimzi with Open Policy Agent demo used in my https://strimzi.io blog post
Open Policy Agent
9
star
22

kafka-test-apps

Apache Kafka producers and consumers written in Vert.x
Java
8
star
23

vertx-grpc-echo

A simple echo server and client written using Vert.x and gRPC
Java
7
star
24

demo-kafka-strimzi-telegram-ml

Demo with Kafka, Strimzi, Telegram and Machine Learning
Java
6
star
25

kafka-at-the-edge

Apache Kafka at the Edge: IoT demo with Apache Kafka
Java
6
star
26

aws-vpc

Terraform configuration for creating s simple Amazon AWS VPC and subnets
HCL
6
star
27

AliasKeyManager

Alternative KeyManager which selects the client private key for client authentication based on specified key alias or selects the first key in the keystore. It doesn't select the client key based on the supported CAs.
Java
6
star
28

echo-sink

Kafka Connect plugin which logs messages into log
Java
6
star
29

devconf-2019-running-apache-kafka-on-kubernetes-and-openshift

DevConf.CZ 2019: Running Apache Kafka on Kubernetes and OpenShift
Shell
5
star
30

terraform-random-kubeadm-token

Terraform module for generating kubeadm tokens
HCL
5
star
31

quarkus-kafka-test-apps

Kafka test applications written using Quarkus
Java
5
star
32

dbg-kubernetes-training

Labs and demos for DBG internal Kubernetes training
4
star
33

strimzi-api-examples

Simple examples using the Strimzi `api` library
Java
4
star
34

amqpctl

CLI client for AMQP Management protocol
Go
4
star
35

demo-jug-ingolstadt

Introduction to Apache Kafka demos for talk in JUG Ingolstadt
4
star
36

kafka-kubernetes-raw-resource-config-provider

Apache Kafka configuration provider for reading data from any Kubernetes resource
Java
4
star
37

demo-amq-streams-webinar

AMQ Streams demo for a Red Hat webinar
Java
4
star
38

dbg-amqp-dispatch-workshop

Examples for the DBG workshop about AMQP and Qpid Dispatch
Java
3
star
39

docker-qpid-cpp

Docker image for Qpid C++ broker
Shell
3
star
40

docker-qpid-dispatch

Docker image for Qpid Dispatch router
Shell
3
star
41

aws-dbg-kubernetes-quickstart

Kubernetes setup based on Heptio / AWS Quickstart adapted to Deutsche Boerse limitations
Python
2
star
42

amqp-java-client-tests

Test suite for testing Java based AMQP 1.0 and 0-10 clients
Java
2
star
43

demo-kubecon-europe-2021-strimzi-office-hours

Demo from the Strimzi Office Hours at KubeCon Europe 2021
2
star
44

vertx-http-echo

A simple echo server and client written using Vert.x and HTTP
Java
2
star
45

what-is-new-in-strimzi

Demos and labs about new features in Strimzi
2
star
46

java-tls-init

Init container for converting X509 certificates to PKCS12 which can be consumed in Java
Shell
2
star
47

milestone-check-action

JavaScript
2
star
48

livescore-demo-vertx-amqp-bridge

LiveScore service demo with AMQP based API using Vert.x AMQP Bridge and Apache Qpid Dispatch
Java
2
star
49

strimzi-apache-kafka-on-kubernetes

Strimzi: Apache Kafka on Kubernetes (Introduction demo)
Java
2
star
50

DoK-Day-KubeCon-EU-2022

Demo for the DoK Day @ KubeCon EU 2022 talk
Java
2
star
51

demo-cloud-native-virtual-summit-china-2020-introduction-to-strimzi

Demo from the "Introduction to Strimzi: Apache Kafka on Kubernetes" talk from Cloud Native + Open Source Virtual Summit China 2020
2
star
52

scholzj

2
star
53

building-cloud-native-logging-pipelines-on-top-of-apache-kafka

Building cloud-native logging pipelines on top of Apache Kafka
Java
2
star
54

strimzi-cistic-odpadu

Strimzi Čistič Odpadů (Drain Cleaner) - Utility to help with draining nodes running Strimzi Kafka or Zookeeper pods
Java
2
star
55

dbg-pti-building-services-and-api-using-amqp

API != HTTP: Building services and APIs using AMQP 1.0 (Deutsche Börse's "Product, Technology and Innovation Conference" 2017)
JavaScript
2
star
56

docker-qpid-proton

Docker image for Qpid Proton
Dockerfile
1
star
57

rh-summit-2019-amq-streams

AMQ Streams demo for Red Hat Summit 2019
Java
1
star
58

build-qpid-proton

Build pipeline for Apache Qpid Proton
Dockerfile
1
star
59

blog-k8s-scalable-amqp

YAML files for the blog article about scalable AMQP setup on kubernetes
1
star
60

aws-jump-host

AWS setup using Terraform and Ansible
Python
1
star
61

devconf-2019-3-ways-to-make-your-life-easier-with-apache-kafka-install-kafka

DevConf.CZ 2019: 3 ways o make your life easier with Apache Kafka
Java
1
star
62

kafka-address-book

Spring application implementing simply Address Book backed by Kafka as data store
Java
1
star
63

my-kafka-client-sandbox

Sandbox repository for Kafka clients and configurations ...
Java
1
star
64

demo-devconfcz-2021-apache-kafka-as-a-monitoring-data-pipeline

DevConf.CZ 2021: Apache Kafka as a Monitoring Data Pipeline
Java
1
star
65

custom-strimzi-principal-builder

Custom Principal Builder for Strimzi based Apache Kafka clusters
Java
1
star
66

amq-streams-quarterly-deep-dive-enablement-demo

Demo repository for the AMQ Streams enablement
1
star
67

devconf-2020-metamorphosis-when-kafka-meets-camel

Shell
1
star
68

circleci-centos-golang

CircleCI 2.0 build image with Go language based on CentOS
Dockerfile
1
star