You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
π¦ build(Dockerfile): optimize Dockerfile for reduced image size
- consolidate RUN commands into a single layer to minimize image size
- add checksum verification for installed tools to enhance security
π docs(README): enhance documentation for AWS EKS Kubernetes CLI
- provide detailed overview and usage instructions
- add sections on troubleshooting and security best practices
π§ chore(action.yml): update action metadata and add input argument
- refine action description and add branding details
- include input argument for kubectl command execution
π fix(entrypoint): improve error handling and tool verification
- add checks for KUBE_CONFIG_DATA existence and decoding
- verify successful installation of kubectl and aws-iam-authenticator
# Docker and GitHub Action for AWS EKS Kubernetes CLI
2
2
3
-
This action provides `kubectl`for Github Actions.
3
+
This action provides a Docker container with `kubectl`, `aws-cli`, and `aws-iam-authenticator` pre-installed for GitHub Actions workflows. It's specifically designed for managing Kubernetes clusters on AWS EKS (Elastic Kubernetes Service).
4
4
5
-
## Usage
5
+
## Overview
6
6
7
-
`.github/workflows/push.yml`
7
+
This container includes:
8
+
- AWS CLI (latest version)
9
+
- kubectl (configurable version)
10
+
- aws-iam-authenticator (configurable version)
11
+
12
+
It allows you to easily run kubectl commands against your AWS EKS clusters directly from your GitHub Actions workflows.
13
+
14
+
## Basic Usage
15
+
16
+
Create a workflow file (e.g., `.github/workflows/deploy.yml`):
8
17
9
18
```yaml
19
+
name: Deploy to EKS
10
20
on: push
11
-
name: deploy
12
21
jobs:
13
22
deploy:
14
-
name: deploy to cluster
23
+
name: Deploy to EKS cluster
15
24
runs-on: ubuntu-latest
16
25
steps:
17
-
- name: Checkout
18
-
uses: actions/checkout@v2
26
+
- name: Checkout code
27
+
uses: actions/checkout@v3
19
28
20
29
- name: Configure AWS credentials
21
30
uses: aws-actions/configure-aws-credentials@v1
@@ -28,7 +37,7 @@ jobs:
28
37
id: login-ecr
29
38
uses: aws-actions/amazon-ecr-login@v1
30
39
31
-
- name: deploy to cluster
40
+
- name: Deploy to EKS cluster
32
41
uses: kodermax/kubectl-aws-eks@main
33
42
env:
34
43
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
@@ -38,73 +47,79 @@ jobs:
38
47
with:
39
48
args: set image deployment/$ECR_REPOSITORY $ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
40
49
41
-
- name: verify deployment
50
+
- name: Verify deployment
42
51
uses: kodermax/kubectl-aws-eks@main
43
52
env:
44
53
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
45
54
with:
46
55
args: rollout status deployment/my-app
47
56
```
48
57
49
-
## Secrets
58
+
## Required Secrets
50
59
51
-
`KUBE_CONFIG_DATA` β **required**: A base64-encoded kubeconfig file with credentials for Kubernetes to access the cluster. You can get it by running the following command:
60
+
### `KUBE_CONFIG_DATA` (Required)
52
61
53
-
### Bash
62
+
A base64-encoded kubeconfig file with credentials for Kubernetes to access the cluster. You can generate this using:
Make sure that your `$HOME/.kube/config` doesn't contain a `AWS_PROFILE`, i.e. remove the following section if it exists before doing the base64 encoding:
75
+
> **Important Security Note**: Before encoding your kubeconfig, ensure it doesn't contain an `AWS_PROFILE` section. If present, remove the following section:
76
+
> ```yaml
77
+
> env:
78
+
> - name: AWS_PROFILE
79
+
> value: github-actions
80
+
> ```
67
81
68
-
```yaml
69
-
env:
70
-
- name: AWS_PROFILE
71
-
value: github-actions
72
-
```
82
+
## Configurable Environment Variables
73
83
74
-
## Configurable Variables
84
+
### `KUBECTL_VERSION` (Optional)
75
85
76
-
`KUBECTL_VERSION` - **optional**: By default, this action pulls the latest version of kubectl. To prevent potential dependency issue, you have the option to only use specific version.
86
+
By default, this action uses the latest stable version of kubectl. To use a specific version:
args: set image deployment/$ECR_REPOSITORY $ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
89
99
```
90
100
91
-
`IAM_VERSION` - **optional**: By default, this action pulls the latest version of aws-iam-authenticator. To prevent potential dependency issue, you have the option to only use specific version.
101
+
### `IAM_VERSION` (Optional)
102
+
103
+
By default, this action uses the latest version of aws-iam-authenticator. To use a specific version:
args: set image deployment/$ECR_REPOSITORY $ECR_REPOSITORY=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
105
116
```
106
117
107
-
## Deploying database changes with Prisma Migrate on Kubernetes
118
+
## Advanced Use Cases
119
+
120
+
### Port Forwarding with Database Migrations
121
+
122
+
This example shows how to use the action as a service to forward a port from a Kubernetes service to your GitHub Actions runner, allowing database migrations to be applied:
108
123
109
124
```yaml
110
125
name: Deploy Database Migrations
@@ -137,5 +152,49 @@ jobs:
137
152
env:
138
153
DATABASE_URL: ${{ secrets.TEST_DATABASE_URL }}
139
154
run: pnpm db-deploy
155
+
```
156
+
157
+
### Running Custom kubectl Commands
158
+
159
+
You can run any kubectl command by passing it as the `args` parameter:
140
160
161
+
```yaml
162
+
- name: Get pod information
163
+
uses: kodermax/kubectl-aws-eks@main
164
+
env:
165
+
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
166
+
with:
167
+
args: get pods -n my-namespace
168
+
```
169
+
170
+
### Applying Kubernetes Manifests
171
+
172
+
```yaml
173
+
- name: Apply Kubernetes manifests
174
+
uses: kodermax/kubectl-aws-eks@main
175
+
env:
176
+
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
177
+
with:
178
+
args: apply -f ./kubernetes/manifests/
141
179
```
180
+
181
+
## Troubleshooting
182
+
183
+
### Common Issues
184
+
185
+
1. **Authentication Errors**: Ensure your KUBE_CONFIG_DATA is correctly base64 encoded and contains valid credentials.
186
+
187
+
2. **Version Compatibility**: If you encounter compatibility issues, try specifying explicit versions for kubectl and aws-iam-authenticator.
188
+
189
+
3. **Permission Issues**: Verify that the service account in your kubeconfig has the necessary permissions to perform the actions in your workflow.
190
+
191
+
## Security Best Practices
192
+
193
+
1. Store your KUBE_CONFIG_DATA as a GitHub secret, never hardcode it in your workflow files.
194
+
195
+
2. Use the principle of least privilege when configuring your kubeconfig file.
196
+
197
+
3. Consider using short-lived credentials or service accounts with limited permissions.
198
+
199
+
4. Regularly rotate your credentials and audit your GitHub Actions workflows.
0 commit comments