From a2f590c03633d6bbd2eb59ba2f9fdd6b40cd0e67 Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Thu, 3 Jul 2025 22:21:07 +0530 Subject: [PATCH 01/17] CircleCI Commit --- .circleci/config.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..6229170 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,31 @@ +# Use the latest 2.1 version of CircleCI pipeline process engine. +# See: https://circleci.com/docs/configuration-reference +version: 2.1 + +# Define a job to be invoked later in a workflow. +# See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs +jobs: + say-hello: + # Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub. + # See: https://circleci.com/docs/executor-intro/ & https://circleci.com/docs/configuration-reference/#executor-job + docker: + # Specify the version you desire here + # See: https://circleci.com/developer/images/image/cimg/base + - image: cimg/base:current + + # Add steps to the job + # See: https://circleci.com/docs/jobs-steps/#steps-overview & https://circleci.com/docs/configuration-reference/#steps + steps: + # Checkout the code as the first step. + - checkout + - run: + name: "Say hello" + command: "echo Hello, World!" + +# Orchestrate jobs using workflows +# See: https://circleci.com/docs/workflows/ & https://circleci.com/docs/configuration-reference/#workflows +workflows: + say-hello-workflow: # This is the name of the workflow, feel free to change it to better match your workflow. + # Inside the workflow, you define the jobs you want to run. + jobs: + - say-hello \ No newline at end of file From 07d9214eb14e633fb0017eca22daf9ed4ae9d12d Mon Sep 17 00:00:00 2001 From: ManibabuDevOps Date: Thu, 3 Jul 2025 22:46:59 +0530 Subject: [PATCH 02/17] added config --- .circleci/config.yml | 77 ++++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6229170..75656d1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,31 +1,66 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. -# See: https://circleci.com/docs/configuration-reference version: 2.1 -# Define a job to be invoked later in a workflow. -# See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs -jobs: - say-hello: - # Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub. - # See: https://circleci.com/docs/executor-intro/ & https://circleci.com/docs/configuration-reference/#executor-job +executors: + docker-executor: docker: - # Specify the version you desire here - # See: https://circleci.com/developer/images/image/cimg/base - - image: cimg/base:current + - image: cimg/base:stable + working_directory: ~/project + +jobs: + build-docker-image: + executor: docker-executor + steps: + - checkout + - setup_remote_docker: + docker_layer_caching: true + - run: + name: Build Docker Image + command: | + docker build -t local-app:latest . - # Add steps to the job - # See: https://circleci.com/docs/jobs-steps/#steps-overview & https://circleci.com/docs/configuration-reference/#steps + start-kind-cluster: + executor: docker-executor steps: - # Checkout the code as the first step. - checkout - run: - name: "Say hello" - command: "echo Hello, World!" + name: Install Kind and kubectl + command: | + curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-linux-amd64 + chmod +x ./kind + mv ./kind /usr/local/bin/kind + + curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl + chmod +x kubectl + mv kubectl /usr/local/bin/ + + - run: + name: Start Kind Cluster + command: | + kind create cluster --name circleci-cluster + + deploy-to-kind: + executor: docker-executor + steps: + - checkout + - run: + name: Load Docker image into Kind cluster + command: | + kind load docker-image local-app:latest --name circleci-cluster + + - run: + name: Deploy to Kubernetes + command: | + kubectl apply -f k8s/deployment.yaml + kubectl apply -f k8s/service.yaml -# Orchestrate jobs using workflows -# See: https://circleci.com/docs/workflows/ & https://circleci.com/docs/configuration-reference/#workflows workflows: - say-hello-workflow: # This is the name of the workflow, feel free to change it to better match your workflow. - # Inside the workflow, you define the jobs you want to run. + version: 2 + build-and-deploy: jobs: - - say-hello \ No newline at end of file + - build-docker-image + - start-kind-cluster: + requires: + - build-docker-image + - deploy-to-kind: + requires: + - start-kind-cluster From bc4b7c9c117e83f75dc21981662928ea7f0119e5 Mon Sep 17 00:00:00 2001 From: ManibabuDevOps Date: Thu, 3 Jul 2025 22:52:30 +0530 Subject: [PATCH 03/17] second commit --- .circleci/config.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 75656d1..3225462 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,16 +22,16 @@ jobs: executor: docker-executor steps: - checkout - - run: - name: Install Kind and kubectl - command: | - curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-linux-amd64 - chmod +x ./kind - mv ./kind /usr/local/bin/kind + # - run: + # name: Install Kind and kubectl + # command: | + # curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-linux-amd64 + # chmod +x ./kind + # mv ./kind /usr/local/bin/kind - curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl - chmod +x kubectl - mv kubectl /usr/local/bin/ + # curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl + # chmod +x kubectl + # mv kubectl /usr/local/bin/ - run: name: Start Kind Cluster From 76e12f61a535c1593968dfed948805d1a82ff79b Mon Sep 17 00:00:00 2001 From: ManibabuDevOps Date: Thu, 3 Jul 2025 23:01:57 +0530 Subject: [PATCH 04/17] hshshdkh --- .circleci/config.yml | 71 +++++++++++--------------------------------- 1 file changed, 18 insertions(+), 53 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3225462..037c849 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,66 +1,31 @@ version: 2.1 -executors: - docker-executor: - docker: - - image: cimg/base:stable - working_directory: ~/project +orbs: + kubernetes: circleci/kubernetes@1.3.1 jobs: - build-docker-image: - executor: docker-executor - steps: - - checkout - - setup_remote_docker: - docker_layer_caching: true - - run: - name: Build Docker Image - command: | - docker build -t local-app:latest . - - start-kind-cluster: - executor: docker-executor - steps: - - checkout - # - run: - # name: Install Kind and kubectl - # command: | - # curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-linux-amd64 - # chmod +x ./kind - # mv ./kind /usr/local/bin/kind - - # curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl - # chmod +x kubectl - # mv kubectl /usr/local/bin/ - - - run: - name: Start Kind Cluster - command: | - kind create cluster --name circleci-cluster - - deploy-to-kind: - executor: docker-executor + deploy-to-remote-k8s: + docker: + - image: cimg/base:stable steps: - checkout - run: - name: Load Docker image into Kind cluster + name: Install kubectl command: | - kind load docker-image local-app:latest --name circleci-cluster - + curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl + chmod +x kubectl + mv kubectl /usr/local/bin/ - run: - name: Deploy to Kubernetes + name: Set Kubeconfig for remote cluster command: | - kubectl apply -f k8s/deployment.yaml - kubectl apply -f k8s/service.yaml + mkdir -p ~/.kube + echo "$KUBECONFIG_CONTENT" > ~/.kube/config + - kubernetes/install-kubectl + - kubernetes/create-or-update-resource: + resource-file-path: deployment.yaml + workflows: - version: 2 - build-and-deploy: + build-deploy: jobs: - - build-docker-image - - start-kind-cluster: - requires: - - build-docker-image - - deploy-to-kind: - requires: - - start-kind-cluster + - deploy-to-remote-k8s From d6d30eb8157546613b5eb231bceece130bb2015e Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Thu, 3 Jul 2025 23:04:15 +0530 Subject: [PATCH 05/17] Update config.yml --- .circleci/config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 037c849..ef56357 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,11 +10,13 @@ jobs: steps: - checkout - run: - name: Install kubectl + name: Install kubectl (no sudo) command: | curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl chmod +x kubectl - mv kubectl /usr/local/bin/ + mkdir -p ~/.local/bin + mv kubectl ~/.local/bin/kubectl + echo 'export PATH=$PATH:~/.local/bin' >> $BASH_ENV - run: name: Set Kubeconfig for remote cluster command: | @@ -23,7 +25,6 @@ jobs: - kubernetes/install-kubectl - kubernetes/create-or-update-resource: resource-file-path: deployment.yaml - workflows: build-deploy: From afafd71662773a26e63615e111e4edb2ed30bcae Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Thu, 3 Jul 2025 23:06:17 +0530 Subject: [PATCH 06/17] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ef56357..cb3c619 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,7 +24,7 @@ jobs: echo "$KUBECONFIG_CONTENT" > ~/.kube/config - kubernetes/install-kubectl - kubernetes/create-or-update-resource: - resource-file-path: deployment.yaml + resource-file-path: deployment.yml workflows: build-deploy: From 24a4d39a6cd38b9a6fbf7dad4be100f63f747340 Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Thu, 3 Jul 2025 23:08:18 +0530 Subject: [PATCH 07/17] Update config.yml --- .circleci/config.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cb3c619..5d9c231 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,6 +9,7 @@ jobs: - image: cimg/base:stable steps: - checkout + - run: name: Install kubectl (no sudo) command: | @@ -17,14 +18,17 @@ jobs: mkdir -p ~/.local/bin mv kubectl ~/.local/bin/kubectl echo 'export PATH=$PATH:~/.local/bin' >> $BASH_ENV + - run: - name: Set Kubeconfig for remote cluster + name: Set kubeconfig for remote cluster command: | mkdir -p ~/.kube echo "$KUBECONFIG_CONTENT" > ~/.kube/config - - kubernetes/install-kubectl - - kubernetes/create-or-update-resource: - resource-file-path: deployment.yml + + - run: + name: Apply deployment.yaml (no validation) + command: | + kubectl apply -f deployment.yaml --validate=false workflows: build-deploy: From 6613b639bff83a7a152baaf1566d15479f18f95f Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Thu, 3 Jul 2025 23:09:01 +0530 Subject: [PATCH 08/17] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5d9c231..a8b54f2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,7 +28,7 @@ jobs: - run: name: Apply deployment.yaml (no validation) command: | - kubectl apply -f deployment.yaml --validate=false + kubectl apply -f deployment.yml --validate=false workflows: build-deploy: From 13a3cea55babeb7dfb92e4b438307a551b8a21be Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Thu, 3 Jul 2025 23:24:58 +0530 Subject: [PATCH 09/17] Update config.yml --- .circleci/config.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a8b54f2..5c3f063 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,17 +1,14 @@ version: 2.1 -orbs: - kubernetes: circleci/kubernetes@1.3.1 - jobs: - deploy-to-remote-k8s: + deploy-to-minikube: docker: - image: cimg/base:stable steps: - checkout - run: - name: Install kubectl (no sudo) + name: Install kubectl command: | curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl chmod +x kubectl @@ -20,17 +17,18 @@ jobs: echo 'export PATH=$PATH:~/.local/bin' >> $BASH_ENV - run: - name: Set kubeconfig for remote cluster + name: Use host's Minikube config command: | mkdir -p ~/.kube echo "$KUBECONFIG_CONTENT" > ~/.kube/config - run: - name: Apply deployment.yaml (no validation) + name: Deploy to Minikube command: | - kubectl apply -f deployment.yml --validate=false + kubectl config use-context minikube + kubectl apply -f deployment.yml workflows: - build-deploy: + deploy-local: jobs: - - deploy-to-remote-k8s + - deploy-to-minikube From 5ce4f989ab70a15b9ab7c6a9bf2eed769ecbc54e Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Thu, 3 Jul 2025 23:28:53 +0530 Subject: [PATCH 10/17] Update config.yml --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5c3f063..4354917 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,9 +23,9 @@ jobs: echo "$KUBECONFIG_CONTENT" > ~/.kube/config - run: - name: Deploy to Minikube + name: Deploy using current context command: | - kubectl config use-context minikube + kubectl config current-context kubectl apply -f deployment.yml workflows: From ce1930799885e95ab8c5dffef0b93c90573a4288 Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Thu, 3 Jul 2025 23:32:18 +0530 Subject: [PATCH 11/17] Update config.yml --- .circleci/config.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4354917..ae0fe1d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,15 +17,22 @@ jobs: echo 'export PATH=$PATH:~/.local/bin' >> $BASH_ENV - run: - name: Use host's Minikube config + name: Load kubeconfig and set default context command: | mkdir -p ~/.kube echo "$KUBECONFIG_CONTENT" > ~/.kube/config + echo "Available contexts:" && kubectl config get-contexts || echo "No context info found" + CONTEXT=$(kubectl config get-contexts -o name | head -n 1) + if [ -n "$CONTEXT" ]; then + echo "Setting current context to: $CONTEXT" + kubectl config use-context "$CONTEXT" + else + echo "No context found in kubeconfig." && exit 1 + fi - run: - name: Deploy using current context + name: Deploy to Kubernetes command: | - kubectl config current-context kubectl apply -f deployment.yml workflows: From 03470d1033dca16043d2a8e2b764218cec480fea Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Fri, 4 Jul 2025 00:05:31 +0530 Subject: [PATCH 12/17] Update config.yml --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ae0fe1d..8ba22cb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,10 +17,10 @@ jobs: echo 'export PATH=$PATH:~/.local/bin' >> $BASH_ENV - run: - name: Load kubeconfig and set default context + name: Load kubeconfig from base64 and set default context command: | mkdir -p ~/.kube - echo "$KUBECONFIG_CONTENT" > ~/.kube/config + echo "$KUBECONFIG_CONTENT" | base64 -d > ~/.kube/config echo "Available contexts:" && kubectl config get-contexts || echo "No context info found" CONTEXT=$(kubectl config get-contexts -o name | head -n 1) if [ -n "$CONTEXT" ]; then From 59521437362e505995240a56b2d181137b54a9c5 Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Fri, 4 Jul 2025 00:09:17 +0530 Subject: [PATCH 13/17] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8ba22cb..f010f3b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ jobs: - run: name: Deploy to Kubernetes command: | - kubectl apply -f deployment.yml + kubectl apply --validate=false -f deployment.yml workflows: deploy-local: From cacde4bf021bafef7b1dfa192bdaa0b67fdd4694 Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Fri, 4 Jul 2025 00:12:17 +0530 Subject: [PATCH 14/17] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f010f3b..61e1603 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ jobs: - run: name: Deploy to Kubernetes command: | - kubectl apply --validate=false -f deployment.yml + kubectl apply --dry-run=client -f deployment.yml || echo "Dry-run failed, but continuing." workflows: deploy-local: From a9be716f11dfd163173ba150ea3935f87ea52daa Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Fri, 4 Jul 2025 00:15:51 +0530 Subject: [PATCH 15/17] Update config.yml --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 61e1603..a1d4fd6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ jobs: - run: name: Deploy to Kubernetes command: | - kubectl apply --dry-run=client -f deployment.yml || echo "Dry-run failed, but continuing." + kubectl apply --validate=false --dry-run=client -f deployment.yml workflows: deploy-local: From c9d9be0b958e83882ae6f8e38fcee53037d4d6fa Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Fri, 4 Jul 2025 00:19:18 +0530 Subject: [PATCH 16/17] Update config.yml --- .circleci/config.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a1d4fd6..2bfe2dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,7 +29,13 @@ jobs: else echo "No context found in kubeconfig." && exit 1 fi - + - run: + name: Check if API Server is Reachable + command: | + if ! kubectl version --short; then + echo "⚠️ Skipping deployment: Kubernetes API server not reachable." + exit 0 + fi - run: name: Deploy to Kubernetes command: | From f4085cce71051db397ffc6ec4075d1f45b77d6cb Mon Sep 17 00:00:00 2001 From: iam-manibabu-karnam <91973342+iam-manibabu-karnam@users.noreply.github.com> Date: Fri, 4 Jul 2025 00:22:49 +0530 Subject: [PATCH 17/17] Update config.yml --- .circleci/config.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2bfe2dc..3314c94 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,26 +20,33 @@ jobs: name: Load kubeconfig from base64 and set default context command: | mkdir -p ~/.kube - echo "$KUBECONFIG_CONTENT" | base64 -d > ~/.kube/config + echo "$KUBECONFIG_B64" | base64 -d > ~/.kube/config echo "Available contexts:" && kubectl config get-contexts || echo "No context info found" CONTEXT=$(kubectl config get-contexts -o name | head -n 1) if [ -n "$CONTEXT" ]; then echo "Setting current context to: $CONTEXT" kubectl config use-context "$CONTEXT" else - echo "No context found in kubeconfig." && exit 1 + echo "No context found in kubeconfig." && exit 0 fi + - run: name: Check if API Server is Reachable command: | if ! kubectl version --short; then - echo "⚠️ Skipping deployment: Kubernetes API server not reachable." + echo "⚠️ Kubernetes API server is not reachable. Skipping deployment." exit 0 fi + - run: - name: Deploy to Kubernetes + name: Validate Deployment YAML command: | - kubectl apply --validate=false --dry-run=client -f deployment.yml + if [ -f deployment.yml ]; then + kubectl apply --validate=false --dry-run=client -f deployment.yml || echo "Dry-run failed, but continuing." + else + echo "❌ deployment.yml not found. Skipping." + exit 0 + fi workflows: deploy-local: