diff --git a/.gitignore b/.gitignore index b7a9d70..b6d358f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,5 @@ .kitchen.local.yml Gemfile.lock terraform.tfstate.d/ -config +kubeconfig config-map-aws-auth.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 34c0893..eca01c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [v0.1.0] - 2018-06-06 +## [v0.1.0] - 2018-06-07 ### Added - Everything! Initial release of the module. +- Kudos to @tanmng for finding and fixing bug #1. diff --git a/README.md b/README.md index 6bc8b03..fb8e0fd 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,9 @@ This module has been packaged with [awspec](https://github.com/k1LoW/awspec) tes 3. Ensure your AWS environment is configured (i.e. credentials and region) for test. 4. Test using `bundle exec kitchen test` from the root of the repo. +For now, connectivity to the kubernetes cluster is not tested but will be in the future. +To test your kubectl connection manually, see the [eks_test_fixture README](https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/examples/eks_test_fixture/README.md). + ## Doc generation Documentation should be modified within `main.tf` and generated using [terraform-docs](https://github.com/segmentio/terraform-docs). diff --git a/data.tf b/data.tf index 26f921d..95ce1b6 100644 --- a/data.tf +++ b/data.tf @@ -29,84 +29,3 @@ data "aws_iam_policy_document" "cluster_assume_role_policy" { } } } - -resource "null_resource" "tags_as_list_of_maps" { - count = "${length(keys(var.tags))}" - - triggers = "${map( - "key", "${element(keys(var.tags), count.index)}", - "value", "${element(values(var.tags), count.index)}", - "propagate_at_launch", "true" - )}" -} - -locals { - asg_tags = ["${null_resource.tags_as_list_of_maps.*.triggers}"] - - # More information: https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/amazon-eks-nodegroup.yaml - workers_userdata = < $CA_CERTIFICATE_FILE_PATH -INTERNAL_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) -sed -i s,MASTER_ENDPOINT,${aws_eks_cluster.this.endpoint},g /var/lib/kubelet/kubeconfig -sed -i s,CLUSTER_NAME,${var.cluster_name},g /var/lib/kubelet/kubeconfig -sed -i s,REGION,${data.aws_region.current.name},g /etc/systemd/system/kubelet.service -sed -i s,MAX_PODS,20,g /etc/systemd/system/kubelet.service -sed -i s,MASTER_ENDPOINT,${aws_eks_cluster.this.endpoint},g /etc/systemd/system/kubelet.service -sed -i s,INTERNAL_IP,$INTERNAL_IP,g /etc/systemd/system/kubelet.service -DNS_CLUSTER_IP=10.100.0.10 -if [[ $INTERNAL_IP == 10.* ]] ; then DNS_CLUSTER_IP=172.20.0.10; fi -sed -i s,DNS_CLUSTER_IP,$DNS_CLUSTER_IP,g /etc/systemd/system/kubelet.service -sed -i s,CERTIFICATE_AUTHORITY_FILE,$CA_CERTIFICATE_FILE_PATH,g /var/lib/kubelet/kubeconfig -sed -i s,CLIENT_CA_FILE,$CA_CERTIFICATE_FILE_PATH,g /etc/systemd/system/kubelet.service -systemctl daemon-reload -systemctl restart kubelet kube-proxy -USERDATA - - config_map_aws_auth = < $CA_CERTIFICATE_FILE_PATH +INTERNAL_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) +sed -i s,MASTER_ENDPOINT,${aws_eks_cluster.this.endpoint},g /var/lib/kubelet/kubeconfig +sed -i s,CLUSTER_NAME,${var.cluster_name},g /var/lib/kubelet/kubeconfig +sed -i s,REGION,${data.aws_region.current.name},g /etc/systemd/system/kubelet.service +sed -i s,MAX_PODS,${lookup(local.max_pod_per_node, var.workers_instance_type)},g /etc/systemd/system/kubelet.service +sed -i s,MASTER_ENDPOINT,${aws_eks_cluster.this.endpoint},g /etc/systemd/system/kubelet.service +sed -i s,INTERNAL_IP,$INTERNAL_IP,g /etc/systemd/system/kubelet.service +DNS_CLUSTER_IP=10.100.0.10 +if [[ $INTERNAL_IP == 10.* ]] ; then DNS_CLUSTER_IP=172.20.0.10; fi +sed -i s,DNS_CLUSTER_IP,$DNS_CLUSTER_IP,g /etc/systemd/system/kubelet.service +sed -i s,CERTIFICATE_AUTHORITY_FILE,$CA_CERTIFICATE_FILE_PATH,g /var/lib/kubelet/kubeconfig +sed -i s,CLIENT_CA_FILE,$CA_CERTIFICATE_FILE_PATH,g /etc/systemd/system/kubelet.service +systemctl daemon-reload +systemctl restart kubelet kube-proxy +USERDATA + + config_map_aws_auth = <