|
| 1 | +# Deploying to Minikube |
| 2 | + |
| 3 | +## Install Minikube |
| 4 | + |
| 5 | +If you haven't an existing installation of Minikube on your computer, [follow the official tutorial](https://minikube.sigs.k8s.io/docs/start/). |
| 6 | + |
| 7 | +When Minkube is installed, start the cluster: |
| 8 | + |
| 9 | + minikube start --addons registry --addons dashboard |
| 10 | + |
| 11 | +The previous command starts Minikube with a Docker registry (we'll use it in the next step) and wih the Kubernetes dashboard. |
| 12 | + |
| 13 | +If you use Mac or Windows, [refer to the documentation](https://minikube.sigs.k8s.io/docs/handbook/registry/#docker-on-macos) to learn how to expose the Docker registry installed as an addon on the port 5000 of the host. |
| 14 | + |
| 15 | +Finally, [install Helm](https://helm.sh/docs/intro/install/). We'll use it to deploy the application in the cluster thanks to the chart provided in the API Platform distribution. |
| 16 | + |
| 17 | +## Building and Pushing Docker Images |
| 18 | + |
| 19 | +First, build the images: |
| 20 | + |
| 21 | + docker build -t localhost:5000/php api --target api_platform_php |
| 22 | + docker build -t localhost:5000/caddy api --target api_platform_caddy |
| 23 | + docker build -t localhost:5000/pwa pwa --target api_platform_pwa_prod |
| 24 | + |
| 25 | +Then push the images in the registry installed in Minikube: |
| 26 | + |
| 27 | + docker push localhost:5000/php |
| 28 | + docker push localhost:5000/caddy |
| 29 | + docker push localhost:5000/pwa |
| 30 | + |
| 31 | +## Deploying |
| 32 | + |
| 33 | +Finally, deploy the project using the Helm chart: |
| 34 | + |
| 35 | + $ helm install my-project helm/api-platform \ |
| 36 | + --set php.image.repository=localhost:5000/php \ |
| 37 | + --set php.image.tag=latest \ |
| 38 | + --set caddy.image.repository=localhost:5000/caddy \ |
| 39 | + --set caddy.image.tag=latest \ |
| 40 | + --set pwa.image.repository=localhost:5000/pwa \ |
| 41 | + --set pwa.image.tag=latest |
| 42 | + |
| 43 | +Copy and paste the commands displayed in the terminal to enable the port forwarding then go to `http://localhost:8080` to access your application! |
| 44 | + |
| 45 | +Run `minikube dashboard` at any moment to see the state of your deployments. |
0 commit comments