Skip to content

Commit

Permalink
Circle CI k8s manifest module (#640)
Browse files Browse the repository at this point in the history
* Circle CI test for K8s manifest module

* configure kubectl

* Add kube config

* update create-and-destroyv workflow
  • Loading branch information
nsarupr authored Jan 31, 2022
1 parent fbb4afd commit 0886588
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .circleci/ci-tests/create-and-destroy-aws/k8s-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: ci-manifest
environments:
- name: awsenv-ci
path: "environment.yml"
variables: {}
modules:
- name: pod
type: k8s-manifest
file_path: ../k8s-manifests/pod-manifest.yaml
9 changes: 9 additions & 0 deletions .circleci/ci-tests/create-and-destroy-gcp/k8s-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: ci-manifest
environments:
- name: gcpenv-ci
path: "environment.yml"
variables: {}
modules:
- name: pod
type: k8s-manifest
file_path: ../k8s-manifests/pod-manifest.yaml
12 changes: 12 additions & 0 deletions .circleci/ci-tests/k8s-manifests/pod-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: default
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
protocol: TCP
90 changes: 90 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,46 @@ jobs:
--config ./.circleci/ci-tests/create-and-destroy-aws/environment.yml \
--auto-approve
aws-test-k8s-manifest:
executor: python-docker
environment:
OPTA_DISABLE_REPORTING: "true"
steps:
- checkout
- attach_workspace:
at: ./
- install-opta-dependencies
- aws-cli/install
- aws-cli/setup
- install-python-dependencies
- run:
name: "Update KUBECONFIG"
command: echo 'export KUBECONFIG="$HOME/kube_config.yaml"' >> $BASH_ENV
- run:
name: "Configure Kubectl"
command: |
./dist/opta/opta configure-kubectl \
--config ./.circleci/ci-tests/create-and-destroy-aws/environment.yml
- run:
name: "Apply K8s Manifest with Opta"
command: |
./dist/opta/opta apply \
--env awsenv-ci \
--config ./.circleci/ci-tests/create-and-destroy-aws/k8s-manifest.yaml \
--auto-approve
- run:
name: "Test manifest pod creation"
command: |
kubectl get pod -n default nginx
exit $?
- run:
name: "Destroy K8s Manifest with Opta"
command: |
yes | ./dist/opta/opta destroy \
--env awsenv-ci \
--config ./.circleci/ci-tests/create-and-destroy-aws/k8s-manifest.yaml \
--auto-approve || if [[ $? -eq 141 ]]; then true; else exit $?; fi
aws-test-service-helm:
executor: ubuntu-machine
environment:
Expand Down Expand Up @@ -956,6 +996,48 @@ jobs:
--config ./.circleci/ci-tests/create-and-destroy-gcp/environment.yml \
--auto-approve
gcp-test-k8s-manifest:
executor: python-docker
environment:
OPTA_DISABLE_REPORTING: "true"
steps:
- checkout
- attach_workspace:
at: ./
- install-opta-dependencies
- gcp-cli/install
- gcp-cli/initialize
- run:
name: "Setting up gcp envar"
command: echo 'export GOOGLE_APPLICATION_CREDENTIALS="/home/circleci/gcloud-service-key.json"' >> $BASH_ENV
- run:
name: "Update KUBECONFIG"
command: echo 'export KUBECONFIG="$HOME/kube_config.yaml"' >> $BASH_ENV
- run:
name: "Configure Kubectl"
command: |
./dist/opta/opta configure-kubectl \
--config ./.circleci/ci-tests/create-and-destroy-gcp/environment.yml
- run:
name: "Apply K8s Manifest with Opta"
command: |
./dist/opta/opta apply \
--env gcpenv-ci \
--config ./.circleci/ci-tests/create-and-destroy-gcp/k8s-manifest.yaml \
--auto-approve
- run:
name: "Test manifest pod creation"
command: |
kubectl get pod -n default nginx
exit $?
- run:
name: "Destroy K8s Manifest with Opta"
command: |
yes | ./dist/opta/opta destroy \
--env gcpenv-ci \
--config ./.circleci/ci-tests/create-and-destroy-gcp/k8s-manifest.yaml \
--auto-approve || if [[ $? -eq 141 ]]; then true; else exit $?; fi
gcp-test-service-helm:
executor: ubuntu-machine
environment:
Expand Down Expand Up @@ -1429,6 +1511,9 @@ workflows:
- aws-test-service-helm:
requires:
- aws-create-env
- aws-test-k8s-manifest:
requires:
- aws-create-env
- aws-destroy-env:
requires:
- aws-test-websocket
Expand All @@ -1440,6 +1525,7 @@ workflows:
- aws-test-service-docdb
- aws-test-service-redis
- aws-test-service-helm
- aws-test-k8s-manifest
- gcp-create-env:
requires:
- build-opta-binary
Expand All @@ -1458,13 +1544,17 @@ workflows:
- gcp-test-service-gcs:
requires:
- gcp-create-env
- gcp-test-k8s-manifest:
requires:
- gcp-create-env
- gcp-destroy-env:
requires:
- gcp-test-additional-nodegroup
- gcp-test-service-pg
- gcp-test-service-redis
- gcp-test-service-helm
- gcp-test-service-gcs
- gcp-test-k8s-manifest
- local-opta-example-create-svcs:
requires:
- build-opta-binary
Expand Down

0 comments on commit 0886588

Please sign in to comment.