From bfa80fdac79672f29172766a2be8c2053e1be0b2 Mon Sep 17 00:00:00 2001 From: Rajdeep Sengupta Date: Sun, 27 Oct 2024 13:33:45 +0530 Subject: [PATCH] Made changes in the up process --- k8s/{ => local}/flexauth-config-map.yaml | 0 k8s/{ => local}/flexauth-service-depl.yaml | 3 +- k8s/{ => local}/mongodb-depl.yaml | 0 k8s/{ => local}/mongodb-express-depl.yaml | 3 +- k8s/{ => local}/smtp-depl.yaml | 0 makefile | 33 +++++++++++++++++++--- skaffold.template.yaml | 2 +- 7 files changed, 32 insertions(+), 9 deletions(-) rename k8s/{ => local}/flexauth-config-map.yaml (100%) rename k8s/{ => local}/flexauth-service-depl.yaml (98%) rename k8s/{ => local}/mongodb-depl.yaml (100%) rename k8s/{ => local}/mongodb-express-depl.yaml (97%) rename k8s/{ => local}/smtp-depl.yaml (100%) diff --git a/k8s/flexauth-config-map.yaml b/k8s/local/flexauth-config-map.yaml similarity index 100% rename from k8s/flexauth-config-map.yaml rename to k8s/local/flexauth-config-map.yaml diff --git a/k8s/flexauth-service-depl.yaml b/k8s/local/flexauth-service-depl.yaml similarity index 98% rename from k8s/flexauth-service-depl.yaml rename to k8s/local/flexauth-service-depl.yaml index 5c8911d..ab21a9c 100644 --- a/k8s/flexauth-service-depl.yaml +++ b/k8s/local/flexauth-service-depl.yaml @@ -85,11 +85,10 @@ metadata: name: flexauth-service namespace: flexauth spec: - type: NodePort + type: LoadBalancer selector: app: flexauth-server ports: - protocol: TCP port: 8080 targetPort: 8080 - nodePort: 30008 diff --git a/k8s/mongodb-depl.yaml b/k8s/local/mongodb-depl.yaml similarity index 100% rename from k8s/mongodb-depl.yaml rename to k8s/local/mongodb-depl.yaml diff --git a/k8s/mongodb-express-depl.yaml b/k8s/local/mongodb-express-depl.yaml similarity index 97% rename from k8s/mongodb-express-depl.yaml rename to k8s/local/mongodb-express-depl.yaml index bd896c8..56bf3b0 100644 --- a/k8s/mongodb-express-depl.yaml +++ b/k8s/local/mongodb-express-depl.yaml @@ -59,5 +59,4 @@ spec: ports: - protocol: TCP port: 8081 - targetPort: 8081 - nodePort: 30000 \ No newline at end of file + targetPort: 8081 \ No newline at end of file diff --git a/k8s/smtp-depl.yaml b/k8s/local/smtp-depl.yaml similarity index 100% rename from k8s/smtp-depl.yaml rename to k8s/local/smtp-depl.yaml diff --git a/makefile b/makefile index 2edd37d..33675bc 100644 --- a/makefile +++ b/makefile @@ -118,20 +118,45 @@ clean: @rm -f $(SKAFFOLD_GENERATED) @echo "Clean-up complete." -# Run flexauth using Skaffold +# Run flexauth using Skaffold and start tunneling with minikube but don't occupy the terminal .PHONY: flexauth-up-k8s up-k8s: @skaffold run -f $(SKAFFOLD_GENERATED) +# start warching the logs of the flexauth server using kubectl +.PHONY: flexauth-logs-k8s +logs-k8s: + @kubectl logs -n $(NAMESPACE) -l app=flexauth-server -f + +# Get the local address of the flexauth server and mongo-express server in minikube +.PHONY: flexauth-address-k8s +flexauth-address-k8s: + @echo "Flexauth is running in minikube. Write "minikube tunnel" to start tunneling." + @echo "Then you will be able to see your servers are running at the following addresses:" + @echo "Flexauth server address: http://127.0.0.1:8080" + @echo "Mongo-express address: http://127.0.0.1:8081" + +# Close minikube tunnel first check if it's running +.PHONY: flexauth-down-tunnel +down-tunnel: + @echo "Checking if Minikube tunnel is running..." + @if pgrep -f "minikube tunnel" > /dev/null; then \ + echo "Minikube tunnel is running. Closing it now..."; \ + pkill -f "minikube tunnel"; \ + echo "Minikube tunnel closed."; \ + else \ + echo "Minikube tunnel is not running."; \ + fi + # Delete all the resources .PHONY: flexauth-down-k8s down-k8s: @echo "Deleting all resources..." - @kubectl delete -f k8s/ - @kubectl delete secret flexauth-secrets + @kubectl delete -f k8s/local + @kubectl delete secret flexauth-secrets -n $(NAMESPACE) @kubectl delete namespace $(NAMESPACE) @echo "All resources deleted." # Final targets -flexauth-up-k8s:setup minikube-up create-namespace create-secret $(SKAFFOLD_GENERATED) up-k8s clean +flexauth-up-k8s: setup minikube-up create-namespace create-secret $(SKAFFOLD_GENERATED) up-k8s clean logs-k8s flexauth-down-k8s: down-k8s clean diff --git a/skaffold.template.yaml b/skaffold.template.yaml index d09834b..2509436 100644 --- a/skaffold.template.yaml +++ b/skaffold.template.yaml @@ -23,4 +23,4 @@ build: deploy: kubectl: manifests: - - k8s/* + - k8s/local/*