mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-01-18 01:27:55 +01:00
Merge pull request #2 from terraform-aws-modules/fix/git_hooks_and_ci
fixing up CI and git hooks
This commit is contained in:
10
.github/PULL_REQUEST_TEMPLATE.md
vendored
10
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -6,8 +6,8 @@ Please explain the changes you made here and link to any relevant issues.
|
||||
|
||||
### Checklist
|
||||
|
||||
* [ ] `terraform fmt` and `terraform validate` both work from the root and `examples/alb_test_fixture` directories (look in CI for an example)
|
||||
* [ ] Tests for the changes have been added and passing (for bug fixes/features)
|
||||
* [ ] Test results are pasted in this PR (in lieu of CI)
|
||||
* [ ] Docs have been added/updated (for bug fixes/features)
|
||||
* [ ] Any breaking changes are noted in the description above
|
||||
- [ ] `terraform fmt` and `terraform validate` both work from the root and `examples/eks_test_fixture` directories (look in CI for an example)
|
||||
- [ ] Tests for the changes have been added and passing (for bug fixes/features)
|
||||
- [ ] Test results are pasted in this PR (in lieu of CI)
|
||||
- [ ] Docs have been added/updated (for bug fixes/features)
|
||||
- [ ] Any breaking changes are noted in the description above
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
repos:
|
||||
- repo: git://github.com/antonbabenko/pre-commit-terraform
|
||||
rev: v1.7.1
|
||||
sha: 091f8b15d7b458e5a0aca642483deb2205e7db02
|
||||
hooks:
|
||||
- id: terraform_fmt
|
||||
# - id: terraform_docs
|
||||
- repo: git://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v1.2.3
|
||||
sha: 92e1570c282e3c69a1f8b5b8dd8d286fe27cfaa7
|
||||
hooks:
|
||||
- id: check-merge-conflict
|
||||
- id: trailing-whitespace
|
||||
|
||||
@@ -26,7 +26,7 @@ script:
|
||||
- echo 'script'
|
||||
- terraform init
|
||||
- terraform fmt -check=true
|
||||
- terraform validate -var "region=${AWS_REGION}" -var "vpc_id=vpc-123456" -var "subnets=['subnet-12345a']" -var "workers_ami_id=ami-123456" -var "cluster_ingress_cidrs=[]" -var "cluster_name=test_cluster"
|
||||
- terraform validate -var "region=${AWS_REGION}" -var "vpc_id=vpc-123456" -var "subnets=[\"subnet-12345a\"]" -var "workers_ami_id=ami-123456" -var "cluster_ingress_cidrs=[]" -var "cluster_name=test_cluster"
|
||||
- docker run --rm -v $(pwd):/app/ --workdir=/app/ -t wata727/tflint --error-with-issues
|
||||
- cd examples/eks_test_fixture
|
||||
- terraform init
|
||||
|
||||
260
local.tf
260
local.tf
@@ -1,130 +1,130 @@
|
||||
locals {
|
||||
# Mapping from the node type that we selected and the max number of pods that it can run
|
||||
# Taken from https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/amazon-eks-nodegroup.yaml
|
||||
max_pod_per_node = {
|
||||
c4.large = 29
|
||||
c4.xlarge = 58
|
||||
c4.2xlarge = 58
|
||||
c4.4xlarge = 234
|
||||
c4.8xlarge = 234
|
||||
c5.large = 29
|
||||
c5.xlarge = 58
|
||||
c5.2xlarge = 58
|
||||
c5.4xlarge = 234
|
||||
c5.9xlarge = 234
|
||||
c5.18xlarge = 737
|
||||
i3.large = 29
|
||||
i3.xlarge = 58
|
||||
i3.2xlarge = 58
|
||||
i3.4xlarge = 234
|
||||
i3.8xlarge = 234
|
||||
i3.16xlarge = 737
|
||||
m3.medium = 12
|
||||
m3.large = 29
|
||||
m3.xlarge = 58
|
||||
m3.2xlarge = 118
|
||||
m4.large = 20
|
||||
m4.xlarge = 58
|
||||
m4.2xlarge = 58
|
||||
m4.4xlarge = 234
|
||||
m4.10xlarge = 234
|
||||
m5.large = 29
|
||||
m5.xlarge = 58
|
||||
m5.2xlarge = 58
|
||||
m5.4xlarge = 234
|
||||
m5.12xlarge = 234
|
||||
m5.24xlarge = 737
|
||||
p2.xlarge = 58
|
||||
p2.8xlarge = 234
|
||||
p2.16xlarge = 234
|
||||
p3.2xlarge = 58
|
||||
p3.8xlarge = 234
|
||||
p3.16xlarge = 234
|
||||
r3.xlarge = 58
|
||||
r3.2xlarge = 58
|
||||
r3.4xlarge = 234
|
||||
r3.8xlarge = 234
|
||||
r4.large = 29
|
||||
r4.xlarge = 58
|
||||
r4.2xlarge = 58
|
||||
r4.4xlarge = 234
|
||||
r4.8xlarge = 234
|
||||
r4.16xlarge = 737
|
||||
t2.small = 8
|
||||
t2.medium = 17
|
||||
t2.large = 35
|
||||
t2.xlarge = 44
|
||||
t2.2xlarge = 44
|
||||
x1.16xlarge = 234
|
||||
x1.32xlarge = 234
|
||||
}
|
||||
|
||||
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 = <<USERDATA
|
||||
#!/bin/bash -xe
|
||||
|
||||
CA_CERTIFICATE_DIRECTORY=/etc/kubernetes/pki
|
||||
CA_CERTIFICATE_FILE_PATH=$CA_CERTIFICATE_DIRECTORY/ca.crt
|
||||
mkdir -p $CA_CERTIFICATE_DIRECTORY
|
||||
echo "${aws_eks_cluster.this.certificate_authority.0.data}" | base64 -d > $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 = <<CONFIGMAPAWSAUTH
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: aws-auth
|
||||
namespace: kube-system
|
||||
data:
|
||||
mapRoles: |
|
||||
- rolearn: ${aws_iam_role.workers.arn}
|
||||
username: system:node:{{EC2PrivateDNSName}}
|
||||
groups:
|
||||
- system:bootstrappers
|
||||
- system:nodes
|
||||
CONFIGMAPAWSAUTH
|
||||
|
||||
kubeconfig = <<KUBECONFIG
|
||||
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
server: ${aws_eks_cluster.this.endpoint}
|
||||
certificate-authority-data: ${aws_eks_cluster.this.certificate_authority.0.data}
|
||||
name: kubernetes
|
||||
contexts:
|
||||
- context:
|
||||
cluster: kubernetes
|
||||
user: aws
|
||||
name: aws
|
||||
current-context: aws
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: aws
|
||||
user:
|
||||
exec:
|
||||
apiVersion: client.authentication.k8s.io/v1alpha1
|
||||
command: heptio-authenticator-aws
|
||||
args:
|
||||
- "token"
|
||||
- "-i"
|
||||
- "${var.cluster_name}"
|
||||
KUBECONFIG
|
||||
}
|
||||
locals {
|
||||
# Mapping from the node type that we selected and the max number of pods that it can run
|
||||
# Taken from https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/amazon-eks-nodegroup.yaml
|
||||
max_pod_per_node = {
|
||||
c4.large = 29
|
||||
c4.xlarge = 58
|
||||
c4.2xlarge = 58
|
||||
c4.4xlarge = 234
|
||||
c4.8xlarge = 234
|
||||
c5.large = 29
|
||||
c5.xlarge = 58
|
||||
c5.2xlarge = 58
|
||||
c5.4xlarge = 234
|
||||
c5.9xlarge = 234
|
||||
c5.18xlarge = 737
|
||||
i3.large = 29
|
||||
i3.xlarge = 58
|
||||
i3.2xlarge = 58
|
||||
i3.4xlarge = 234
|
||||
i3.8xlarge = 234
|
||||
i3.16xlarge = 737
|
||||
m3.medium = 12
|
||||
m3.large = 29
|
||||
m3.xlarge = 58
|
||||
m3.2xlarge = 118
|
||||
m4.large = 20
|
||||
m4.xlarge = 58
|
||||
m4.2xlarge = 58
|
||||
m4.4xlarge = 234
|
||||
m4.10xlarge = 234
|
||||
m5.large = 29
|
||||
m5.xlarge = 58
|
||||
m5.2xlarge = 58
|
||||
m5.4xlarge = 234
|
||||
m5.12xlarge = 234
|
||||
m5.24xlarge = 737
|
||||
p2.xlarge = 58
|
||||
p2.8xlarge = 234
|
||||
p2.16xlarge = 234
|
||||
p3.2xlarge = 58
|
||||
p3.8xlarge = 234
|
||||
p3.16xlarge = 234
|
||||
r3.xlarge = 58
|
||||
r3.2xlarge = 58
|
||||
r3.4xlarge = 234
|
||||
r3.8xlarge = 234
|
||||
r4.large = 29
|
||||
r4.xlarge = 58
|
||||
r4.2xlarge = 58
|
||||
r4.4xlarge = 234
|
||||
r4.8xlarge = 234
|
||||
r4.16xlarge = 737
|
||||
t2.small = 8
|
||||
t2.medium = 17
|
||||
t2.large = 35
|
||||
t2.xlarge = 44
|
||||
t2.2xlarge = 44
|
||||
x1.16xlarge = 234
|
||||
x1.32xlarge = 234
|
||||
}
|
||||
|
||||
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 = <<USERDATA
|
||||
#!/bin/bash -xe
|
||||
|
||||
CA_CERTIFICATE_DIRECTORY=/etc/kubernetes/pki
|
||||
CA_CERTIFICATE_FILE_PATH=$CA_CERTIFICATE_DIRECTORY/ca.crt
|
||||
mkdir -p $CA_CERTIFICATE_DIRECTORY
|
||||
echo "${aws_eks_cluster.this.certificate_authority.0.data}" | base64 -d > $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 = <<CONFIGMAPAWSAUTH
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: aws-auth
|
||||
namespace: kube-system
|
||||
data:
|
||||
mapRoles: |
|
||||
- rolearn: ${aws_iam_role.workers.arn}
|
||||
username: system:node:{{EC2PrivateDNSName}}
|
||||
groups:
|
||||
- system:bootstrappers
|
||||
- system:nodes
|
||||
CONFIGMAPAWSAUTH
|
||||
|
||||
kubeconfig = <<KUBECONFIG
|
||||
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
server: ${aws_eks_cluster.this.endpoint}
|
||||
certificate-authority-data: ${aws_eks_cluster.this.certificate_authority.0.data}
|
||||
name: kubernetes
|
||||
contexts:
|
||||
- context:
|
||||
cluster: kubernetes
|
||||
user: aws
|
||||
name: aws
|
||||
current-context: aws
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: aws
|
||||
user:
|
||||
exec:
|
||||
apiVersion: client.authentication.k8s.io/v1alpha1
|
||||
command: heptio-authenticator-aws
|
||||
args:
|
||||
- "token"
|
||||
- "-i"
|
||||
- "${var.cluster_name}"
|
||||
KUBECONFIG
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user