Skip to content

Shared crossplane action refactor #137

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

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7f8a459
Fix crossplane script downloading
kieranajp Oct 8, 2024
ca9ba68
rossplane new CI
kieranajp Oct 9, 2024
b424626
update vpcConfig
libracoder Oct 31, 2024
ec4a110
update backend config
libracoder Nov 5, 2024
59df2ca
update backend config
libracoder Nov 5, 2024
abc4a5b
crossplane for prod
libracoder Nov 26, 2024
f19fcda
update subnets
libracoder Nov 28, 2024
fc8d1e5
run_zip_lambda_workflow_step set to false
libracoder Nov 29, 2024
3b2a0c0
run_zip_lambda_workflow_step set to false
libracoder Dec 3, 2024
f2a6927
update PR role
libracoder Dec 9, 2024
16a7e1f
add support for lambda in release ci
libracoder Dec 12, 2024
fbaf211
upgrade PR ci for crossplane
libracoder Dec 12, 2024
159347a
upgrade PR ci for crossplane
libracoder Dec 12, 2024
c64def0
add aws account id
libracoder Dec 13, 2024
4f55b10
add aws account id
libracoder Dec 13, 2024
db1dad2
handle LykonEventSourceMapping
libracoder Jan 13, 2025
a591ccd
handles all other as kinesis
libracoder Jan 13, 2025
4231ae2
update kind to XLykonLambdaDockerImage
libracoder Jan 13, 2025
b01c694
update kind to XLykonLambdaDockerImage
libracoder Jan 13, 2025
0b77b38
updated staging kubeconfig
libracoder Jan 23, 2025
9636d0c
updated staging kubeconfig
libracoder Jan 23, 2025
ca7c721
updated staging kubeconfig
libracoder Jan 23, 2025
7e8b519
updated staging kubeconfig
libracoder Jan 23, 2025
3583b1d
updated staging kubeconfig
libracoder Jan 23, 2025
b1e7ba6
updated staging kubeconfig
libracoder Jan 23, 2025
4676890
updated staging kubeconfig
libracoder Jan 23, 2025
41fc5e8
update XEventSourceMapping stream
libracoder Feb 3, 2025
c536229
add XLykonS3EventSourceMapping
libracoder Feb 4, 2025
c395df3
remove XLykonS3EventSourceMapping
libracoder Feb 4, 2025
4066780
fix modify-claims.sh
libracoder Feb 5, 2025
dd5ba49
fix modify-claims.sh
libracoder Feb 5, 2025
dc8b911
prd kubeconfig
libracoder Apr 6, 2025
43409a1
fix
libracoder Apr 7, 2025
fd58327
fix
libracoder Apr 7, 2025
68aef01
fix
libracoder Apr 7, 2025
2a5c9a3
fix
libracoder Apr 7, 2025
d1235bc
fix
libracoder Apr 7, 2025
dbe9314
Allow passing in role
kieranajp Apr 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions .github/workflows/crossplane-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
on:
workflow_call:
inputs:
environment:
required: true
type: string
service_name:
required: true
type: string

permissions:
id-token: write
contents: read
pull-requests: write
statuses: write

jobs:
crossplane-terraform:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
-
name: Checkout shared-actions
uses: actions/checkout@v4
with:
repository: vimeda/shared-actions
path: ./scripts
ref: feature/shared-crossplane
-
name: Checkout service
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
path: ./scripts/${{ inputs.service_name }}
-
name: Install yq
uses: chrisdickinson/setup-yq@v1.0.1
with:
yq-version: v4.25.3
-
name: Install 1Password CLI
uses: 1password/install-cli-action@v1
-
name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-kubernetes-role
role-session-name: ga-${{ inputs.service_name }}
aws-region: eu-central-1
-
name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ~1.9

#build lambdas zip or lambda docker images

- name: Build lambdas
if: ${{inputs.run_zip_lambda_workflow_step == true}}
run: cd ${{ github.workspace }} && make lambda
env:
GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }}
GOPRIVATE: "github.com/vimeda/*"

- name: Upload Build Artifacts
if: ${{inputs.run_zip_lambda_workflow_step == true}}
uses: actions/upload-artifact@v4
with:
name: srv-lambdas
path: ${{ github.workspace }}/dist/*

- uses: actions/download-artifact@v4
id: download
if: ${{inputs.run_zip_lambda_workflow_step == true}}
with:
name: srv-lambdas
path: ${{ github.workspace }}/dist

- name: Display structure of downloaded files
if: ${{env.run_zip_lambda_workflow_step == true}}
run: ls -R
working-directory: ${{ steps.download.outputs.download-path }}
env:
run_zip_lambda_workflow_step: ${{ inputs.run_zip_lambda_workflow_step }}

- name: Push all functions to Bucket
if: ${{env.run_zip_lambda_workflow_step == true}}
run: |
cd ${{ github.workspace }}/dist && ls
for file in "./"/*lambda.zip
do
filename=$(basename "$file" .zip)
function_name=${filename%_lambda}
aws s3 cp "$file" "s3://${{inputs.env}}-lykon-lambdas/${{ github.event.repository.name}}/$function_name.zip"
done
env:
run_zip_lambda_workflow_step: ${{ inputs.run_zip_lambda_workflow_step }}

#apply terraform

-
name: Terraform Init
working-directory: ./scripts/crossplane
run: |
terraform init \
-backend-config="region=eu-central-1" \
-backend-config="bucket=terraform-eks" \
-backend-config="key=crossplane/${{ inputs.environment }}/${{ inputs.service_name }}"

-
name: Terraform Validate
working-directory: ./scripts/crossplane
run: |
terraform validate -no-color
-
name: Verify Kubeconfig
working-directory: ./scripts/crossplane
run: |
if [ -z "$KUBECONFIG" ]; then
echo "Error: KUBECONFIG environment variable is not set"
exit 1
fi

# Test if we can connect to the cluster using the kubeconfig directly
if ! echo "$KUBECONFIG" | base64 -d | kubectl --kubeconfig=/dev/stdin cluster-info; then
echo "Error: Unable to connect to Kubernetes cluster"
exit 1
fi

echo "Kubeconfig verification successful"
env:
KUBECONFIG: ${{ secrets.PRD_KUBECONFIG }}

- name: Terraform
working-directory: ./scripts/crossplane
run: |
# Create and decode kubeconfig
echo "${{ secrets.PRD_KUBECONFIG }}" | base64 -d > ${{ github.workspace }}/kubeconfig.yaml
chmod 600 ${{ github.workspace }}/kubeconfig.yaml

# Set KUBECONFIG environment variable
export KUBECONFIG=${{ github.workspace }}/kubeconfig.yaml

# Verify kubectl can connect to the cluster
kubectl cluster-info

# Create provider configuration file
cat > provider.tf << EOF
provider "kubectl" {
config_path = "${{ github.workspace }}/kubeconfig.yaml"
apply_retry_count = 5
load_config_file = true
}
EOF

# Run terraform apply
terraform apply -auto-approve -no-color \
-var-file=${{ inputs.environment }}.tfvars \
-var="commit_hash=${{ github.sha }}" \
-var="service_name=${{ inputs.service_name }}"
env:
TF_WORKSPACE: ${{ inputs.environment }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.PROD_ONEPASSWORD_SERVICEACCOUNT_TOKEN }}
AWS_DEFAULT_REGION: eu-central-1


138 changes: 138 additions & 0 deletions .github/workflows/crossplane.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
on:
workflow_call:
inputs:
environment:
required: true
type: string
service_name:
required: true
type: string
run_zip_lambda_workflow_step:
type: boolean
default: false
role_name:
type: string
default: 'github-actions-kubernetes-role'
role_session_name:
type: string
default: 'ga-kubernetes'


permissions:
id-token: write
contents: read
pull-requests: write
statuses: write

jobs:
crossplane-terraform:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
-
name: Checkout shared-actions
uses: actions/checkout@v4
with:
repository: vimeda/shared-actions
path: ./scripts
ref: feature/shared-crossplane
-
name: Checkout service
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
path: ./scripts/${{ inputs.service_name }}
-
name: Install yq
uses: chrisdickinson/setup-yq@v1.0.1
with:
yq-version: v4.25.3
-
name: Install 1Password CLI
uses: 1password/install-cli-action@v1
-
name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ inputs.role_name }}
role-session-name: ${{ inputs.role_session_name }}
aws-region: eu-central-1
-
name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ~1.9

#build lambdas zip or lambda docker images

- name: Build lambdas
if: ${{inputs.run_zip_lambda_workflow_step == true}}
run: cd ${{ github.workspace }} && make lambda
env:
GITHUB_TOKEN: ${{ secrets.GB_TOKEN_PRIVATE }}
GOPRIVATE: "github.com/vimeda/*"

- name: Upload Build Artifacts
if: ${{inputs.run_zip_lambda_workflow_step == true}}
uses: actions/upload-artifact@v4
with:
name: srv-lambdas
path: ${{ github.workspace }}/dist/*

- uses: actions/download-artifact@v4
id: download
if: ${{inputs.run_zip_lambda_workflow_step == true}}
with:
name: srv-lambdas
path: ${{ github.workspace }}/dist

- name: Display structure of downloaded files
if: ${{env.run_zip_lambda_workflow_step == true}}
run: ls -R
working-directory: ${{ steps.download.outputs.download-path }}
env:
run_zip_lambda_workflow_step: ${{ inputs.run_zip_lambda_workflow_step }}

- name: Push all functions to Bucket
if: ${{env.run_zip_lambda_workflow_step == true}}
run: |
cd ${{ github.workspace }}/dist && ls
for file in "./"/*lambda.zip
do
filename=$(basename "$file" .zip)
function_name=${filename%_lambda}
aws s3 cp "$file" "s3://${{inputs.env}}-lykon-lambdas/${{ github.event.repository.name}}/$function_name.zip"
done
env:
run_zip_lambda_workflow_step: ${{ inputs.run_zip_lambda_workflow_step }}

#apply terraform

-
name: Terraform Init
working-directory: ./scripts/crossplane
run: |
terraform init \
-backend-config="region=eu-central-1" \
-backend-config="bucket=terraform-eks" \
-backend-config="key=crossplane/${{ inputs.environment }}/${{ inputs.service_name }}"

-
name: Terraform Validate
working-directory: ./scripts/crossplane
run: |
terraform validate -no-color
-
name: Terraform
working-directory: ./scripts/crossplane
run: |
echo "${{ secrets.STG_KUBECONFIG }}" > ${{ github.workspace }}/kubeconfig.yaml
export KUBECONFIG=${{ github.workspace }}/kubeconfig.yaml
terraform apply -auto-approve -no-color \
-var-file=${{ inputs.environment }}.tfvars \
-var="commit_hash=${{ github.sha }}" \
-var="service_name=${{ inputs.service_name }}"
env:
TF_WORKSPACE: ${{ inputs.environment }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.STAGING_ONEPASSWORD_SERVICEACCOUNT_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/kubeconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: v1
kind: Config
preferences: {}
current-context: arn:aws:eks:eu-central-1:279707217826:cluster/prd-eks-v2

clusters:
- name: arn:aws:eks:eu-central-1:279707217826:cluster/prd-eks-v2
cluster:
server: https://6FAE7EA31F6ABDC83D35085CD36856A9.gr7.eu-central-1.eks.amazonaws.com
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURCVENDQWUyZ0F3SUJBZ0lJZXBDbzlyUGFBN1V3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TlRBME1ETXhOekk1TlRGYUZ3MHpOVEEwTURFeE56TTBOVEZhTUJVeApFekFSQmdOVkJBTVRDbXQxWW1WeWJtVjBaWE13Z2dFaU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQkR3QXdnZ0VLCkFvSUJBUURsYXRxcENFaHhjNHZuR1Q2U3htbzcwY3pFZ0M2Nm5TR2NwaDdNeTl4Njg4UTZTSWV6MFFyTnNPM3IKdExjaGRsaWtpREdZU1RwK2dmUlVNWDN5UjdYVTVyTHVEaktWWkh1N21XTTR4RFEwenhkNlVKcGd5NFRzK0kvbwpmc0NESnZoOUdtRjk4Z2kxdTdvTnorU0d3OXdFd3U1MzJsbEVtUXRTclpSemZuNHFYOUk1b1hRSXB0dkd3ekxXCk1ON0RmSjVTTGZIWlloblZPTmJUeCtQOWN4QW0yMXhVdGRYUlFIaXRJbklxZnFsTlhsYWlLbWlwQUNNRlJtazQKeTFETElVM1lWZDk0eGtJcDlVTFdMTnRjZ2NtWEdvZUMyMGhDUXJnRkJWaC9LRlNlQmNkOWQ2eVdySjFhVCtKUgovWEJTa1BvMWNBMDBjYy9jajNjWjVhZ3ozSXEvQWdNQkFBR2pXVEJYTUE0R0ExVWREd0VCL3dRRUF3SUNwREFQCkJnTlZIUk1CQWY4RUJUQURBUUgvTUIwR0ExVWREZ1FXQkJSeUF5aGd2Rm1LY2plTFcvNUNia0M0R2hYUFVEQVYKQmdOVkhSRUVEakFNZ2dwcmRXSmxjbTVsZEdWek1BMEdDU3FHU0liM0RRRUJDd1VBQTRJQkFRQ0VQNUVzc0pnMAo5VW03TkZId0FRN0JWdCs0VWJkR3VQZEdaU0JDVWFwS1pCN05tUlFKdGtac05oRHJkQngydlpGZjVDWm1iUzB1CkhrRVJpSjc3K2hweWtuSEVKZmdyMjV0NWZ1cFBUdXRWU3V6ZTBicEJFMmZheEZpQy9kQlQ5bjBlK2lRVnd0SUkKemxGbVZBQUVRU2VSQjNqdFhFTk1CSUdOSXhoSUw4ZGRPVnFLQmdRWm9tZGlvdzhRRVRYV29iSzZLM3ZUVmRKcwozYmVUZ204NTZYdnRuSGtWM0JmTTFRK1dMTm1DYlYzeS9SODBHd3drQXJaK01VN2J1Q1hOUkhqem9qTkx0UEdTCmk3cjdZVmlUenlvTHFubVBub3N6VFZzTVh4YWxLelNnSGlQOGxFNUhWM2xQYm9TeUFnMm13ZEVVRFQ2ZkFzb0cKK2ROY1BBUnNwVUpvCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K

contexts:
- name: arn:aws:eks:eu-central-1:279707217826:cluster/prd-eks-v2
context:
cluster: arn:aws:eks:eu-central-1:279707217826:cluster/prd-eks-v2
user: arn:aws:eks:eu-central-1:279707217826:cluster/prd-eks-v2

users:
- name: arn:aws:eks:eu-central-1:279707217826:cluster/prd-eks-v2
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
command: aws
args:
- --region
- eu-central-1
- eks
- get-token
- --cluster-name
- prd-eks-v2
2 changes: 1 addition & 1 deletion .github/workflows/main-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ jobs:
release: ${{ inputs.release_name }}
namespace: ${{ inputs.namespace }}
env:
KUBECONFIG_FILE: ${{ secrets.STAGING_KUBECONFIG }}
KUBECONFIG_FILE: ${{ secrets.STG_KUBECONFIG }}
Loading