网页
综合
更新时间 2026-11-13 15:31:10
Hello Minikube | Kubernetes
自动蜘蛛
kubernetes.io
正文约 3866 字
This tutorial shows you how to run a sample app on Kubernetes using minikube. The tutorial provides a container image that uses NGINX to echo back all the requests.
This tutorial assumes that you have already set up minikube. See Step 1 in minikube start for installation instructions.
You also need to install kubectl. See Install tools for installation instructions.
Verify the status of the minikube cluster to ensure all the components are in a running state.
The output from the above command should show all components Running or Configured, as shown in the example output below:
Open the Kubernetes dashboard. You can do this two different ways:
Open a new terminal, and run:
Now, switch back to the terminal where you ran minikube start.
You can create Kubernetes resources on the dashboard such as Deployment and Service.
To find out how to avoid directly invoking the browser from the terminal and get a URL for the web dashboard, see the "URL copy and paste" tab.
By default, the dashboard is only accessible from within the internal Kubernetes virtual network. The dashboard command creates a temporary proxy to make the dashboard accessible from outside the Kubernetes virtual network.
To stop the proxy, run Ctrl+C to exit the process. After the command exits, the dashboard remains running in the Kubernetes cluster. You can run the dashboard command again to create another proxy to access the dashboard.
If you don't want minikube to open a web browser for you, run the dashboard subcommand with the --url flag. minikube outputs a URL that you can open in the browser you prefer.
Open a new terminal, and run:
Now, you can use this URL and switch back to the terminal where you ran minikube start.
A Kubernetes Pod is a group of one or more Containers, tied together for the purposes of administration and networking. The Pod in this tutorial has only one Container. A Kubernetes Deployment checks on the health of your Pod and restarts the Pod's Container if it terminates. Deployments are the recommended way to manage the creation and scaling of Pods.
Use the kubectl create command to create a Deployment that manages a Pod. The Pod runs a Container based on the provided Docker image.
View the Deployment:
The output is similar to:
(It may take some time for the pod to become available. If you see "0/1", try again in a few seconds.)
The output is similar to:
View cluster events:
View the kubectl configuration:
View application logs for a container in a pod (replace pod name with the one you got from kubectl get pods).
The output is similar to:
By default, the Pod is only accessible by its internal IP address within the Kubernetes cluster. To make the hello-node Container accessible from outside the Kubernetes virtual network, you have to expose the Pod as a Kubernetes Service.
Expose the Pod to the public internet using the kubectl expose command:
The --type=LoadBalancer flag indicates that you want to expose your Service outside of the cluster.
The application code inside the test image only listens on TCP port 8080. If you used kubectl expose to expose a different port, clients could not connect to that other port.
View the Service you created:
The output is similar to:
On cloud providers that support load balancers, an external IP address would be provisioned to access the Service. On minikube, the LoadBalancer type makes the Service accessible through the minikube service command.
Run the following command:
This opens up a browser window that serves your app and shows the app's response.
The minikube tool includes a set of built-in addons that can be enabled, disabled and opened in the local Kubernetes environment.
List the currently supported addons:
The output is similar to:
Enable an addon, for example, metrics-server:
The output is similar to:
View the Pod and Service you created by installing that addon:
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。