
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
This is your first Kubernetes "Hello World" application. It is an Nginx web server that listens on 80 port and when you connect to it with your browser the "Hello World!" message will appear with hostname and image version. This will be useful to understand which Pod responded to browser request and its IP and which version is currently in use.
Kubernetes allows to run a containerized application in three ways:
The methods 1 and 2 are achieved via kubectl CLI while the method 3 is achieved declaring the desired state in a YAML configuration file. Let's analyze all this methods in details.
This is the easiest method and it is achieved using the commands kubect run and kubectl expose. It is useful when you want to run a quick test just to check if the application container works in a Pod. Since no deployment is created behind the scene you cannot scale the Pod.
The command to run the application is:
kubectl run hello-k8s --generator=run-pod/v1 --image=sasadangelo/hello-k8s:latest --port=80
Check if the Pod is running typing the command:
kubectl get pods
In order to connect with the browser from your host machine you need to expose the Pod via Service using the following command:
kubectl expose pod hello-k8s --type=NodePort --port=80
You can type now in your browser the URL ÌP:PORT where IP is the 192.168.x.x address of one of the two worker nodes ( k8s-node-1 or k8s-node-2 ) and PORT is the one you get typing the command:
kubectl describe service hello-k8s | grep NodePort
Clean up the configuration using the commands:
kubectl delete service hello-k8s kubectl delete pod hello-k8s
This method is achieved using the commands kubect create and kubectl expose. The first command create a deployment behind the scene so you can scale the Pos as you prefer.
The command to deploy and run the application is:
kubectl create deployment hello-k8s --image=sasadangelo/hello-k8s:latest
Check if the Deployment is created and the Pod is running typing the commands:
kubectl get deployments kubectl get pods
In order to connect with the browser from your host machine you need to expose the Deployment via Service using the following command:
kubectl expose deployment hello-k8s --type=NodePort --port=80
You can type now in your browser the URL ÌP:PORT where IP is the 192.168.x.x address of one of the two worker nodes ( k8s-node-1 or k8s-node-2 ) and PORT is the one you get typing the command:
kubectl describe service hello-k8s | grep NodePort
You can scale the application to 5 pods with the following commands:
kubectl scale --replicas=5 deployment.apps/hello-k8s
You can see the 5 pods running using the kubectl get pods command. If you type your browser Reload button continuosly you can notice sometime the hostname change because different pods will respond. Attention!!! It could be possible you have to type the Reload button a lots of time before see the hostname change due to Pod affinity.
Clean up the configuration using the commands:
kubectl delete service hello-k8s kubectl delete deployment deployment.apps/hello-k8s
This method is achieved using the commands kubect apply. This command uses a deployment file where is defined the deployment and the service resource objects.
The command to deploy and run the application is:
kubectl apply -f https://raw.githubusercontent.com/sasadangelo/k8s-tutorials/master/hello-k8s/deployment.yml
You can see 5 pods running using the kubectl get pods command. You can type now in your browser the URL ÌP:PORT where IP is the 192.168.x.x address of one of the two worker nodes ( k8s-node-1 or k8s-node-2 ) and PORT is the one you get typing the command:
kubectl describe service hello-k8s-service -n hello-k8s-ns | grep NodePort
Clean up the configuration using the commands:
kubectl delete service hello-k8s-service kubectl delete deployment deployment.apps/hello-k8s-deployment kubectl delete namespace hello-k8s-ns
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务