Skip to content
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

Wifi 13871 #957

Merged
merged 8 commits into from
Sep 18, 2024
Merged
Changes from all commits
Commits
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
164 changes: 90 additions & 74 deletions .github/workflows/cgw-dev-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,26 @@ defaults:
shell: bash

env:
AWS_EKS_NAME: tip-wlan-main
#AWS_EKS_NAME: tip-wlan-main
AWS_EKS_NAME: tip-wlan-qa
AWS_DEFAULT_OUTPUT: json
AWS_DEFAULT_REGION: ap-south-1
AWS_DEFAULT_REGION: us-east-1
#AWS_DEFAULT_REGION: ap-south-1
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CLIENT_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CLIENT_KEY }}

# # https://stackoverflow.com/questions/59977364/github-actions-how-use-strategy-matrix-with-script
# # Required object fiels per environment:
# # - namespace - namespace suffix that will used added for the Kubernetes environment (i.e. if you pass 'test', kubernetes namespace will be named 'openlan-test')
# # - cgw_version - OpenLAN Cloud Gateway version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)
# # - just_component - if true then deploy only cgw chart
# https://stackoverflow.com/questions/59977364/github-actions-how-use-strategy-matrix-with-script
# Required object fiels per environment:
# - namespace - namespace suffix that will used added for the Kubernetes environment (i.e. if you pass 'test', kubernetes namespace will be named 'openlan-test')
# - deploy_repo_version - wlan_cloud_ucentral_deploy repo version to use
# - cgw_version - OpenLAN Cloud Gateway version to deploy (will be used for Docker image tag and git branch for Helm chart if git deployment is required)
# - just_component - if true then deploy only cgw chart
testbeds: '[
{
"namespace": "cgw01",
"chart_version": "main",
"cgw_version": "main",
"deploy_repo_version": "main",
"cgw_version": "next",
"just_component": "false"
}
]'
Expand Down Expand Up @@ -53,12 +56,12 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: generate-matrix
id: set-matrix
run: |
cat >> $GITHUB_OUTPUT << EOF
matrix={"include":${{ env.testbeds }}}
EOF
- name: generate-matrix
id: set-matrix
run: |
cat >> $GITHUB_OUTPUT << EOF
matrix={"include":${{ env.testbeds }}}
EOF

deploy:
name: Update OpenLAN Cloud Gateway instances
Expand All @@ -70,68 +73,81 @@ jobs:
matrix: ${{ fromJson( needs.generate-matrix.outputs.matrix ) }}
fail-fast: false
steps:
- name: Checkout repo with Helm values
uses: actions/checkout@v4
with:
repository: Telecominfraproject/wlan-cloud-ucentral-deploy
path: wlan-cloud-ucentral-deploy
ref: ${{ matrix.chart_version }}
- name: Checkout repo with Helm values
uses: actions/checkout@v4
with:
repository: Telecominfraproject/wlan-cloud-ucentral-deploy
path: wlan-cloud-ucentral-deploy
ref: ${{ matrix.deploy_repo_version }}

- name: Fetch kubeconfig
run: |
aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }}
- name: Checkout cgw repo
uses: actions/checkout@v4
with:
repository: Telecominfraproject/openlan-cgw
path: openlan-cgw
ref: ${{ matrix.cgw_version }}

- name: Install kubectl, helmfile and plugins
run: |
curl -s -LO "https://dl.k8s.io/release/v1.27.14/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
curl -s -LO "https://github.com/helmfile/helmfile/releases/download/v0.165.0/helmfile_0.165.0_linux_amd64.tar.gz"
tar xvzf helmfile_0.165.0_linux_amd64.tar.gz helmfile
sudo install -o root -g root -m 0755 helmfile /usr/local/bin/helmfile
helm plugin install https://github.com/aslafy-z/helm-git --version 0.16.0
helm plugin install https://github.com/databus23/helm-diff
helm plugin install https://github.com/jkroepke/helm-secrets
- name: Fetch kubeconfig
run: |
aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }}

- name: Create certificate file
working-directory: wlan-cloud-ucentral-deploy/cgw
run: |
echo "${{ env.DIGICERT_CERT }}" | base64 -d > websocket-cert.pem
echo "${{ env.DIGICERT_KEY }}" | base64 -d > websocket-key.pem
./mkcertconfig websocket-cert.pem websocket-key.pem > values/certs.device.yaml
kubectl create secret generic certs --dry-run=client -o yaml \
--from-file=websocket-key.pem --from-file=websocket-cert.pem \
| grep websocket- >> values/certs.device.yaml
- name: Install kubectl, helmfile and plugins
run: |
curl -s -LO "https://dl.k8s.io/release/v1.27.14/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
curl -s -LO "https://github.com/helmfile/helmfile/releases/download/v0.165.0/helmfile_0.165.0_linux_amd64.tar.gz"
tar xvzf helmfile_0.165.0_linux_amd64.tar.gz helmfile
sudo install -o root -g root -m 0755 helmfile /usr/local/bin/helmfile
helm plugin install https://github.com/aslafy-z/helm-git --version 0.16.0
helm plugin install https://github.com/databus23/helm-diff
helm plugin install https://github.com/jkroepke/helm-secrets

- name: Deploy OpenLAN Cloud Gateway and services
if: ${{ github.event.inputs.just_component }} == "false"
working-directory: wlan-cloud-ucentral-deploy/cgw
run: |
# service components can't be reinstalled easily
helm ls -n ${{ matrix.namespace }}
if ! helm ls -n ${{ matrix.namespace }} | grep "^kafka" >/dev/null ; then
helmfile --environment ${{ matrix.namespace }} apply
else
helmfile --environment ${{ matrix.namespace }} -l app=cgw apply
fi
- name: Create certificate file
working-directory: wlan-cloud-ucentral-deploy/cgw
run: |
echo "${{ env.DIGICERT_CERT }}" | base64 -d > websocket-cert.pem
echo "${{ env.DIGICERT_KEY }}" | base64 -d > websocket-key.pem
./mkcertconfig websocket-cert.pem websocket-key.pem > values/certs.device.yaml
kubectl create secret generic certs --dry-run=client -o yaml \
--from-file=websocket-key.pem --from-file=websocket-cert.pem \
| grep websocket- >> values/certs.device.yaml

- name: Deploy OpenLAN Cloud Gateway only
if: ${{ github.event.inputs.just_component }} == "true"
working-directory: wlan-cloud-ucentral-deploy/cgw
run: |
helmfile --environment ${{ matrix.namespace }} -l app=cgw apply
- name: Deploy OpenLAN Cloud Gateway and services
if: ${{ github.event.inputs.just_component }} == "false"
working-directory: wlan-cloud-ucentral-deploy/cgw
run: |
# service components can't be reinstalled easily
helm ls -n ${{ matrix.namespace }}
if ! helm ls -n ${{ matrix.namespace }} | grep "^kafka" >/dev/null ; then
helmfile --environment ${{ matrix.namespace }} \
--state-values-set "cgw.tag={{ matrix.cgw_version }}"
apply
else
helmfile --environment ${{ matrix.namespace }} -l app=cgw \
--state-values-set "cgw.tag={{ matrix.cgw_version }}" \
apply
fi

- name: Show resource state on deployment failure
if: failure()
run: |
echo "Pods:"
kubectl get pods --namespace openlan-${{ matrix.namespace }}
echo "Pod Descriptions:"
kubectl describe pods --namespace openlan-${{ matrix.namespace }}
echo "Services:"
kubectl get services --namespace openlan-${{ matrix.namespace }}
echo "Service Descriptions:"
kubectl describe services --namespace openlan-${{ matrix.namespace }}
echo "PVCs:"
kubectl get persistentvolumeclaims --namespace openlan-${{ matrix.namespace }}
echo "PVC Descriptions:"
kubectl describe persistentvolumeclaims --namespace openlan-${{ matrix.namespace }}
- name: Deploy OpenLAN Cloud Gateway only
if: ${{ github.event.inputs.just_component }} == "true"
working-directory: wlan-cloud-ucentral-deploy/cgw
run: |
helmfile --environment ${{ matrix.namespace }} -l app=cgw \
--state-values-set "cgw.tag={{ matrix.cgw_version }}" \
apply

- name: Show resource state on deployment failure
if: failure()
run: |
echo "Pods:"
kubectl get pods --namespace openlan-${{ matrix.namespace }}
echo "Pod Descriptions:"
kubectl describe pods --namespace openlan-${{ matrix.namespace }}
echo "Services:"
kubectl get services --namespace openlan-${{ matrix.namespace }}
echo "Service Descriptions:"
kubectl describe services --namespace openlan-${{ matrix.namespace }}
echo "PVCs:"
kubectl get persistentvolumeclaims --namespace openlan-${{ matrix.namespace }}
echo "PVC Descriptions:"
kubectl describe persistentvolumeclaims --namespace openlan-${{ matrix.namespace }}
Loading