- Built from the provided
Dockerfile. - Contains the compiled Go controller (
main.go). - When run, this image connects to the Kubernetes API and creates:
- A Deployment (
go-book-app) that runs the book application container (istiaka2i/bookapp:v1.0). - A NodePort Service (
go-book-service) to expose the app.
- A Deployment (
- Defines a Pod that runs the controller image.
- Uses the
go-book-app-saServiceAccount for RBAC permissions. - When this Pod starts, it triggers the controller logic:
- The controller creates the Deployment and Service in the cluster.
- Created by the controller Pod.
- Runs the book application image:
istiaka2i/bookapp:v1.0. - The Deployment ensures two replicas of the app are running.
- Also created by the controller Pod.
- Exposes the book app on port 4000 (mapped to container port 8080) and NodePort 30080.
[Controller Image: create-deploy]
|
v
[Controller Pod: go-book-app-controller.yaml]
|
v
[Controller Logic: main.go]
|
v
[Creates Deployment: go-book-app] ----> [Runs bookapp:v1.0]
|
v
[Creates Service: go-book-service] ----> [Exposes app via NodePort]
- You build and deploy the controller image.
- The controller Pod runs and triggers the creation of the book app Deployment and Service.
- The book app image is pulled and run by the Deployment, and exposed by the Service.
-
Build Controller Image
docker build -t istiaka2i/create-deploy:latest . -
Apply RBAC
kubectl apply -f rbac.yaml
-
Deploy Controller Pod
kubectl apply -f go-book-app-controller.yaml
-
Check Resources
kubectl get pods kubectl get deployments kubectl get services
This workflow ensures that the controller image, when run as a Pod, automatically provisions your book app and exposes it in the cluster.