From 56967cc77e2503e5154ec4bd8d78565fe91499ed Mon Sep 17 00:00:00 2001 From: Joel Wembo Date: Wed, 17 Apr 2024 17:24:20 +0800 Subject: [PATCH] added new jenkinsfiles --- .../{Jenkinsfile-2 => Jenkinsfile-python} | 0 ...{Jenkinsfile-1 => Jenkinsfile-script-base} | 0 deployments/Jenkins/JenkinsfileEKS | 20 ++++++++++++++++++- deployments/deploy-aws-eks-cluster.sh | 4 ++-- 4 files changed, 21 insertions(+), 3 deletions(-) rename deployments/Jenkins/{Jenkinsfile-2 => Jenkinsfile-python} (100%) rename deployments/Jenkins/{Jenkinsfile-1 => Jenkinsfile-script-base} (100%) diff --git a/deployments/Jenkins/Jenkinsfile-2 b/deployments/Jenkins/Jenkinsfile-python similarity index 100% rename from deployments/Jenkins/Jenkinsfile-2 rename to deployments/Jenkins/Jenkinsfile-python diff --git a/deployments/Jenkins/Jenkinsfile-1 b/deployments/Jenkins/Jenkinsfile-script-base similarity index 100% rename from deployments/Jenkins/Jenkinsfile-1 rename to deployments/Jenkins/Jenkinsfile-script-base diff --git a/deployments/Jenkins/JenkinsfileEKS b/deployments/Jenkins/JenkinsfileEKS index c6f765f..be7b409 100644 --- a/deployments/Jenkins/JenkinsfileEKS +++ b/deployments/Jenkins/JenkinsfileEKS @@ -34,13 +34,31 @@ pipeline { steps { script { // Push your Docker image to the registry - docker.withRegistry(DOCKER_REGISTRY_URL, 'docker-credentials-id') { + docker.withRegistry(DOCKER_REGISTRY_URL, 'globaldockerhub') { docker.image("${DOCKER_REGISTRY_URL}/${APP_NAME}:${DOCKER_IMAGE_TAG}").push() } } } } + + stage('Create EKS Cluster') { + steps { + script { + sh "eksctl create cluster - name mycluster - nodegroup-name ng-test - node-type t3.medium - nodes 2" + + } + } + } + + stage('update-kubeconfig') { + steps { + script { + sh "aws eks --region us-east-1 update-kubeconfig --name mycluster" + + } + } + } stage('Deploy to EKS') { steps { diff --git a/deployments/deploy-aws-eks-cluster.sh b/deployments/deploy-aws-eks-cluster.sh index 65326d9..d4e7057 100644 --- a/deployments/deploy-aws-eks-cluster.sh +++ b/deployments/deploy-aws-eks-cluster.sh @@ -6,7 +6,7 @@ NAMESPACE="cloudapp-django-web" DOCKER_IMAGE="joelwembo/cloudapp-django-web:latest" DEPLOYMENT_NAME="cloudapp-django-web" SERVICE_NAME="mycluster" -PORT=80 +PORT=8585 # Set KUBECONFIG environment variable export KUBECONFIG="$KUBECONFIG" @@ -18,4 +18,4 @@ kubectl apply -f deployments/k8s/deployment.yaml kubectl set image deployment/$DEPLOYMENT_NAME $DEPLOYMENT_NAME=$DOCKER_IMAGE -n $NAMESPACE # Expose the deployment as a service -kubectl expose deployment cloudapp-django-web --type=LoadBalancer --port=80 --target-port=8585-n $NAMESPACE --name=cloudapp-django-web +kubectl expose deployment $DEPLOYMENT_NAME --type=LoadBalancer --port=80 --target-port=$PORT -n $NAMESPACE --name=cloudapp-django-web