Last active
May 20, 2020 02:56
-
-
Save zxkane/289037c851af8077e31fbf867ef2d82f to your computer and use it in GitHub Desktop.
Create a EKS cluster with IAM for service account
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
--- | |
apiVersion: eksctl.io/v1alpha5 | |
kind: ClusterConfig | |
metadata: | |
name: cluster-3 | |
region: cn-northwest-1 | |
nodeGroups: | |
- name: ng2-private | |
instanceType: m5.large | |
desiredCapacity: 2 | |
privateNetworking: true |
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
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 | |
kind: Deployment | |
metadata: | |
name: nginx-deployment | |
namespace: backend-apps | |
spec: | |
selector: | |
matchLabels: | |
app: nginx | |
replicas: 2 # tells deployment to run 2 pods matching the template | |
template: | |
metadata: | |
labels: | |
app: nginx | |
spec: | |
serviceAccount: s3-reader | |
serviceAccountName: s3-reader | |
containers: | |
- name: nginx | |
image: nginx:latest | |
ports: | |
- containerPort: 80 | |
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
--- | |
apiVersion: eksctl.io/v1alpha5 | |
kind: ClusterConfig | |
metadata: | |
name: cluster-3 | |
region: cn-northwest-1 | |
iam: | |
withOIDC: true | |
serviceAccounts: | |
- metadata: | |
name: s3-reader | |
# if no namespace is set, "default" will be used; | |
# the namespace will be created if it doesn't exist already | |
namespace: backend-apps | |
labels: {aws-usage: "application"} | |
attachPolicyARNs: | |
- "arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess" | |
- metadata: | |
name: cache-access | |
namespace: backend-apps | |
labels: {aws-usage: "application"} | |
attachPolicyARNs: | |
- "arn:aws:iam::aws:policy/AmazonDynamoDBReadOnlyAccess" | |
- "arn:aws:iam::aws:policy/AmazonElastiCacheFullAccess" | |
- metadata: | |
name: cluster-autoscaler | |
namespace: kube-system | |
labels: {aws-usage: "cluster-ops"} | |
attachPolicy: # inline policy can be defined along with `attachPolicyARNs` | |
Version: "2012-10-17" | |
Statement: | |
- Effect: Allow | |
Action: | |
- "autoscaling:DescribeAutoScalingGroups" | |
- "autoscaling:DescribeAutoScalingInstances" | |
- "autoscaling:DescribeLaunchConfigurations" | |
- "autoscaling:DescribeTags" | |
- "autoscaling:SetDesiredCapacity" | |
- "autoscaling:TerminateInstanceInAutoScalingGroup" | |
Resource: '*' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.