Skip to content

Conversation

tei-k
Copy link
Contributor

@tei-k tei-k commented Nov 12, 2020

Description

https://scalar-labs.atlassian.net/browse/DLT-7400

Done

  • Add Kubernetes module for AWS
  • Only support node group

Confirm

  • Terraform apply
$ cd example/aws/kubernetes
$ terraform apply -var-file=example.tfvars
  • Copy configuration files (scalar-k8/conf)
    • inventory.ini
    • kube_config (Copy from ${eks_cluster_name}_kubeconfig)
  • Fix scalar-k8/conf/scalardl-custom-values.yaml
-      service.beta.kubernetes.io/azure-load-balancer-internal: "true"
-      service.beta.kubernetes.io/azure-load-balancer-internal-subnet: "k8s_ingress"
+      service.beta.kubernetes.io/aws-load-balancer-type: clb
+      service.beta.kubernetes.io/aws-load-balancer-internal: "true"
+      # service.beta.kubernetes.io/azure-load-balancer-internal: "true"
+      # service.beta.kubernetes.io/azure-load-balancer-internal-subnet: "k8s_ingress"
  • ansible-playbook (scalar-k8/)
$ ansible-playbook -i ${SCALAR_K8S_CONFIG_DIR}/inventory.ini playbooks/playbook-install-tools.yml
$ ansible-playbook -i ${SCALAR_K8S_CONFIG_DIR}/inventory.ini playbooks/playbook-deploy-scalardl.yml
$ ansible-playbook -i ${SCALAR_K8S_CONFIG_DIR}/inventory.ini playbooks/playbook-deploy-prometheus.yml
  • Get resources
$ k get pod,svc -o wide

Ref

@tei-k tei-k self-assigned this Nov 12, 2020
@tei-k tei-k changed the title []Add kubernetes module for aws [WIP] Add kubernetes module for aws Nov 12, 2020
@tei-k tei-k force-pushed the add-kubenertes-for-aws branch from 1abce85 to 17b6577 Compare November 12, 2020 07:46
@tei-k tei-k force-pushed the add-kubenertes-for-aws branch from 78e95f4 to a0f49e5 Compare November 16, 2020 05:17
@tei-k tei-k force-pushed the add-kubenertes-for-aws branch from 60afe87 to 15ac1f9 Compare November 16, 2020 23:51
@tei-k tei-k changed the title [WIP] Add kubernetes module for aws Add kubernetes module for aws Nov 20, 2020
@tei-k tei-k requested review from feeblefakie and ymorimo November 20, 2020 07:35
Copy link
Collaborator

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looking good. Left some suggestions and comments.

variable "kubernetes_cluster" {
type = map
default = {}
description = "Custom definition kubernetes properties that include name of the cluster, kubernetes version, etc.."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description = "Custom definition kubernetes properties that include name of the cluster, kubernetes version, etc.."
description = "Custom definition kubernetes properties that include the name of the cluster, kubernetes version, etc.."

}

variable "kubernetes_node_groups" {
description = "Map of map of node groups to create"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really a map of map? or typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It's a map of maps.

@@ -0,0 +1,96 @@
resource "aws_iam_role" "eks_cluster" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add a subsection for privileges in EKS deployment?
https://github.com/scalar-labs/scalar-terraform/blob/master/docs/CloudPrivileges.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,45 @@
# Optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the other examples, the default region should be here at the top of example.tfvars.
(I didn't use the default ap-northeast-1 region and I got lost when terraform apply couldn't find the VPC that the network module created.)

Suggested change
# Optional
region = "ap-northeast-1"
# Optional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! 👍
Also added backend.tf.s3 and remote.tf.s3 in 41f7f45

@ymorimo
Copy link
Contributor

ymorimo commented Nov 25, 2020

@tei-k Question.

I got the following kube_config output after terraform apply,

clusters:
- cluster:
    server: https://D0BE5C2FAD77ED66ED29817523BB7182.yl4.us-west-1.eks.amazonaws.com
    certificate-authority-data: LS0tLS1CRUdJTiBDRV...

but the server host in that file resolves to private IP addresses. Because of this kubectl fails to communicate with the endpoint.

$ host d0be5c2fad77ed66ed29817523bb7182.yl4.us-west-1.eks.amazonaws.com
d0be5c2fad77ed66ed29817523bb7182.yl4.us-west-1.eks.amazonaws.com has address 10.42.1.144
d0be5c2fad77ed66ed29817523bb7182.yl4.us-west-1.eks.amazonaws.com has address 10.42.41.117

Can you tell what is happening?

@tei-k
Copy link
Contributor Author

tei-k commented Nov 25, 2020

@ymorimo

but the server host in that file resolves to private IP addresses. Because of this kubectl fails to communicate with the endpoint.

Good point! 👍 Sorry for missing of explanation on this point.

Because cluster_endpoint_public_access is false in the current default setting, So cannot access this endpoint from local.
To operate from the bastion we need to set up authentication manually.

Can you first create environment with cluster_endpoint_public_access = "true" ?

example.tfvars

# cluster_endpoint_private_access      = "true"
cluster_endpoint_public_access       = "true"

Copy link
Collaborator

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Please create a PR for the update in scalardl-custom-values.yaml once this PR is merged.
Also, please write a getting started doc once Yusuke's doc reorganization is completed.

Copy link
Contributor

@ymorimo ymorimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It worked. Thanks. LGTM!

@feeblefakie feeblefakie merged commit ca97c22 into master Nov 30, 2020
@feeblefakie feeblefakie deleted the add-kubenertes-for-aws branch November 30, 2020 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants