This commit is contained in:
u1 2024-11-02 07:27:01 +00:00
parent 1192c7a0bd
commit 5e6d057383
4 changed files with 44 additions and 1 deletions

1
__build Normal file
View File

@ -0,0 +1 @@
docker build -f Dockerfile -t zoz:latest ..

2
__vp
View File

@ -2,6 +2,6 @@ f() {
sudo docker run --rm -dit --privileged \
-v "$(pwd)/app:/home/user/work" \
-p 3333:3333 \
--name "$1" deb su - user;
--name "$1" zoz:latest su - user;
};
f $1

Binary file not shown.

View File

@ -81,5 +81,47 @@ kubectl run my-app --image=localhost:5000/my-app:latest --image-pull-policy=IfNo
\end{lstlisting}
\end{enumerate}
\section{Adding a Docker Image to Minikube and Exposing It}
\subsection{Load Docker Image into Minikube}
1. \textbf{Build and Load Docker Image Directly into Minikube:}
If the image is built locally, you can load it directly into Minikube:
\begin{lstlisting}
minikube image load my-app:latest
\end{lstlisting}
Alternatively, if you are using a local registry, ensure Minikube can access it by setting the registry address in the image tag.
\subsection{Create and Run a Pod with the Loaded Image}
1. \textbf{Create a Deployment in Minikube:}
Create a Kubernetes Deployment to manage the pod using the loaded image:
\begin{lstlisting}
kubectl create deployment my-app --image=my-app:latest
\end{lstlisting}
2. \textbf{Expose the Deployment as a Service:}
Expose the Deployment to make the application accessible on an external port:
\begin{lstlisting}
kubectl expose deployment my-app --type=NodePort --port=80 --target-port=8080
\end{lstlisting}
In this example, Kubernetes maps port 80 of the service to port 8080 of the container. Modify `target-port` if your application uses a different port.
\subsection{Access the Application Externally}
1. \textbf{Retrieve the Minikube Service URL:}
Minikube provides a command to get the external URL for accessing services. Run the following command to get the URL:
\begin{lstlisting}
minikube service my-app --url
\end{lstlisting}
This command will output a URL that you can use to access the service from outside of Minikube.
\end{document}