forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 3
STAC-4766 aws-eks kubernetes services #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
97f5011
chore(eks): Refresh aws eks setup and k8s manifests
TizianoPerrucci 342b6bb
chore(eks): Join manifests. Testing multiple pods/services. Add netto…
TizianoPerrucci dbcac22
Merge branch 'master' into STAC-4766-eks
TizianoPerrucci 2f94e08
Merge branch 'master' into STAC-4766-eks
TizianoPerrucci File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| eks_rsa* | ||
| eks.deploy |
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions
42
Dockerfiles/manifests/aws-eks/k8s/connection_test/pod-to-service-cluster-ip-2.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: pod-server-2 | ||
| labels: | ||
| type: server-2 | ||
| spec: | ||
| containers: | ||
| - image: itsthenetwork/alpine-ncat | ||
| name: server-2 | ||
| command: ["/bin/bash", "-c", "ncat -vv --broker --listen -p 123 > /dev/null"] | ||
| ports: | ||
| - containerPort: 123 | ||
| nodeSelector: | ||
| failure-domain.beta.kubernetes.io/zone: us-east-1a | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: pod-service-2 | ||
| labels: | ||
| type: service-2 | ||
| spec: | ||
| type: ClusterIP | ||
| ports: | ||
| - port: 654 | ||
| protocol: TCP | ||
| targetPort: 123 | ||
| selector: | ||
| type: server-2 | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: pod-client-2 | ||
| spec: | ||
| containers: | ||
| - image: jgkamat/netcat | ||
| name: client-2 | ||
| command: ["/bin/bash", "-c", "yes | nc -vv pod-service-2 654"] | ||
| nodeSelector: | ||
| failure-domain.beta.kubernetes.io/zone: us-east-1b |
42 changes: 42 additions & 0 deletions
42
Dockerfiles/manifests/aws-eks/k8s/connection_test/pod-to-service-cluster-ip.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: pod-server | ||
| labels: | ||
| type: server | ||
| spec: | ||
| containers: | ||
| - image: itsthenetwork/alpine-ncat | ||
| name: server | ||
| command: ["/bin/bash", "-c", "ncat -vv --broker --listen -p 123 > /dev/null"] | ||
| ports: | ||
| - containerPort: 123 | ||
| nodeSelector: | ||
| failure-domain.beta.kubernetes.io/zone: us-east-1a | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: pod-service | ||
| labels: | ||
| type: service | ||
| spec: | ||
| type: ClusterIP | ||
| ports: | ||
| - port: 321 | ||
| protocol: TCP | ||
| targetPort: 123 | ||
| selector: | ||
| type: server | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: pod-client | ||
| spec: | ||
| containers: | ||
| - image: jgkamat/netcat | ||
| name: client | ||
| command: ["/bin/bash", "-c", "yes | nc -vv pod-service 321"] | ||
| nodeSelector: | ||
| failure-domain.beta.kubernetes.io/zone: us-east-1b |
60 changes: 60 additions & 0 deletions
60
Dockerfiles/manifests/aws-eks/k8s/connection_test/tcptracer-bpf-nettop.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| apiVersion: apps/v1 | ||
| kind: DaemonSet | ||
| metadata: | ||
| name: tcptracer-bpf-nettop | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app: tcptracer-bpf-nettop | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: tcptracer-bpf-nettop | ||
| name: tcptracer-bpf-nettop | ||
| spec: | ||
| serviceAccountName: stackstate-agent | ||
| containers: | ||
| - image: stackstate/tcptracer-bpf-nettop:latest | ||
| imagePullPolicy: Always | ||
| name: stackstate-agent | ||
| securityContext: | ||
| privileged: true | ||
| resources: | ||
| requests: | ||
| memory: "256Mi" | ||
| cpu: "200m" | ||
| limits: | ||
| memory: "256Mi" | ||
| cpu: "200m" | ||
| volumeMounts: | ||
| - name: sys-kernel-debug | ||
| mountPath: /sys/kernel/debug | ||
| - name: dockersocket | ||
| mountPath: /var/run/docker.sock | ||
| - name: procdir | ||
| mountPath: /host/proc | ||
| readOnly: true | ||
| - name: passwd | ||
| mountPath: /etc/passwd | ||
| readOnly: true | ||
| - name: cgroups | ||
| mountPath: /host/sys/fs/cgroup | ||
| readOnly: true | ||
| hostNetwork: true | ||
| hostPID: true | ||
| volumes: | ||
| - hostPath: | ||
| path: /sys/kernel/debug | ||
| name: sys-kernel-debug | ||
| - hostPath: | ||
| path: /var/run/docker.sock | ||
| name: dockersocket | ||
| - hostPath: | ||
| path: /proc | ||
| name: procdir | ||
| - hostPath: | ||
| path: /etc/passwd | ||
| name: passwd | ||
| - hostPath: | ||
| path: /sys/fs/cgroup | ||
| name: cgroups |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Dockerfiles/manifests/aws/tf/Makefile → ...les/manifests/aws-eks/tf-cluster/Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # Kubernetes Cluster Setup | ||
|
|
||
| Important: setup follows https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html as of commit date. | ||
|
|
||
| In order to start with cluster setup, you will need: | ||
|
|
||
| - Terraform | ||
| - AWS credentials with necessary rights | ||
| - AWS authenticator for EKS, called heptio authenticator: | ||
| ``` | ||
| curl -o <PATH>/heptio-authenticator-aws https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/bin/linux/amd64/heptio-authenticator-aws | ||
| curl -o <PATH>/heptio-authenticator-aws.md5 https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-06-05/bin/linux/amd64/heptio-authenticator-aws.md5 | ||
| chmod +x <PATH>/heptio-authenticator-aws | ||
| ``` | ||
|
|
||
| ## Variables | ||
|
|
||
| Create an ssh key pair that will be used for login in to the EC2 instances: | ||
|
|
||
| `ssh-keygen -f eks_rsa` | ||
|
|
||
| Set the following environment variables: | ||
|
|
||
| ``` | ||
| export AWS_ACCESS_KEY_ID= | ||
| export AWS_SECRET_ACCESS_KEY= | ||
| export TF_VAR_AWS_SECRET_ACCESS_KEY=... | ||
| export TF_VAR_AWS_ACCESS_KEY_ID=... | ||
| export TF_VAR_AWS_REGION=us-east-1 | ||
| export TF_VAR_CLUSTER_NAME=... | ||
| ``` | ||
|
|
||
| ## Deploy | ||
|
|
||
| ### Plan and apply | ||
|
|
||
| First `make plan` to check what changes Terraform will apply, then deploy the changes with `make apply`. | ||
|
|
||
| The operation takes around 20mins. | ||
|
|
||
| ### Output | ||
|
|
||
| Output are: | ||
|
|
||
| - `kubeconfig` file produced by `make kubeconfig` | ||
|
|
||
| You can `export KUBECONFIG=<PATH>/tf/kubeconfig` to let kubectl know how to connect to cluster. | ||
|
|
||
| - policy that will allow worker nodes to join cluster `terraform output config-map-aws-auth` | ||
|
|
||
| ### Destroy | ||
|
|
||
| As simple as `make destroy`. | ||
|
|
||
| ## Configure kubectl | ||
|
|
||
| To allow kubectl to talk to your cluster `make kubeconfig` and follow the suggestion to export kube config path. | ||
|
|
||
| Make sure nodes can register `make config-map-aws-auth` and wait for nodes to appear. | ||
|
|
||
| Your are now ready. | ||
|
|
||
| ## Kubernetes dashboard | ||
|
|
||
| Follow the documentation here https://docs.aws.amazon.com/eks/latest/userguide/dashboard-tutorial.html | ||
|
|
||
|
|
||
| ### Working with multiple clusters at a time | ||
|
|
||
| By default, terraform creates one state file, that you will need to replace, if you are working with another cluster. | ||
| To smoothly work with multiple clusters, you can use terraform workspaces (https://www.terraform.io/docs/state/workspaces.html) | ||
|
|
||
| For example, you can create workspace by cluster name before provisioning cluster, and use `${terraform.workspace}` | ||
| as a cluster name `cluster_name= "${terraform.workspace}-cluster"` | ||
|
|
||
| `terraform workspace new dummy` | ||
|
|
||
| view workspaces: | ||
|
|
||
| ``` | ||
| terraform workspace list | ||
| default | ||
| * dummy | ||
| ``` | ||
|
|
||
| select specific workplace: | ||
|
|
||
| ``` | ||
| terraform workspace select dummy | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
Dockerfiles/manifests/aws/k8s/connection_test/pod-client.yaml
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
Dockerfiles/manifests/aws/k8s/connection_test/pod-server.yaml
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
Dockerfiles/manifests/aws/k8s/connection_test/pod-service.yaml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.