diff --git a/.github/workflows/ci-maven.yml b/.github/workflows/ci-maven.yml index b10a08f..320d0c2 100644 --- a/.github/workflows/ci-maven.yml +++ b/.github/workflows/ci-maven.yml @@ -33,6 +33,39 @@ jobs: - name: Build api-gateway with Maven run: mvn -B package --file api-gateway/pom.xml + - name: Start minikube + uses: medyagh/setup-minikube@master + + - name: Try the cluster ! + run: kubectl get pods -A + + - name: Build image + run: | + pwd + ls -la + eval $(minikube -p minikube docker-env) + cd api-gateway/ + pwd + ls -la + docker build -t api-gateway . + echo -n "verifying images:" + docker images + + - name: Deploy to minikube + run: | + pwd + ls -la + kubectl apply -f api-gateway/.helm/templates/k8s-api-gateway-app.yaml + kubectl wait --for=condition=ready pod -l app=api-gateway + + - name: Test service URLs + run: | + minikube service list + SERVICE_URL=$(minikube service api-gateway-service --url) + HEALTH_URL="$SERVICE_URL/actuator/health" + echo "Service URL: $SERVICE_URL" + echo "Health URL: $HEALTH_URL" + build_openai_service: runs-on: ubuntu-latest # https://stackoverflow.com/a/70448851 diff --git a/api-gateway/.helm/templates/k8s-api-gateway-app.yaml b/api-gateway/.helm/templates/k8s-api-gateway-app.yaml new file mode 100644 index 0000000..6a09d08 --- /dev/null +++ b/api-gateway/.helm/templates/k8s-api-gateway-app.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment # Kubernetes resource kind +metadata: + name: api-gateway +spec: + selector: + matchLabels: + app: api-gateway + replicas: 3 # Number of replicas that will be created for this deployment + template: + metadata: + labels: + app: api-gateway + spec: + containers: + - name: api-gateway + image: api-gateway:latest # Image that will be used to containers in the cluster + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8080 # The port that the container is running on in the cluster + +--- + +apiVersion: v1 # Kubernetes API version +kind: Service # Kubernetes resource kind +metadata: # Metadata of the resource kind + name: api-gateway-service +spec: + selector: + app: api-gateway + ports: + - protocol: "TCP" + port: 8080 # The port that the service is running on in the cluster + targetPort: 8080 # The port exposed by the service + type: NodePort # Type of the service. Service types: NodePort, ClusterIp, LoadBalancer