In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article is about how to publish the container to the K8S cluster. The editor thinks it is very practical, so I hope you can get something after reading this article. Let's take a look at it with the editor.
Preface
Today, I ran a containerized application in the K8S cluster.
Publish the container to the container source in K8S
Use the official container image of nginx.
Two ways to publish a container
With the image, there are two ways to submit it to K8S for operation:
Command line mode (not recommended).
Profile method (recommended).
The second officially recommended method is used here, which is by writing various information about the container to the configuration file and submitting it to K8S.
Define Container profile
Create a nginx.yaml file
[root@master01 ~] # cat nginx.yaml apiVersion: v1kind: Podmetadata: name: nginxspec:-name: nginx image: nginx:1.7.9 ports:-containerPort: 80 hostAliases:-ip: "10.20.20.20" hostnames:-"test1.com"-"test2.com" deployment container to K8S [root@master01 ~] # kubectl apply-f nginx.yaml pod/nginx created view Operation of the container [root@master01 ~] # kubectl get pods-o wideNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATESnginx 1 Running 093s 192.10.205.195 work01 to view the specific information of the container
All important actions are recorded in the Events returned by the kubectl describe instruction for DEBUG
[root@master01] # kubectl describe pod nginxName: nginxNamespace: defaultPriority: 0Node: work03/192.168.10.17IP: 192.10.137.130. Omit .events: Type Reason Age From Message-Normal Scheduled default-scheduler Successfully assigned default/nginx to work03 Normal Pulled 74s kubelet, work03 Container image "nginx:1.7.9" already present on machine Normal Created 73s kubelet Work03 Created container nginx Normal Started 73s kubelet, nginx version in work03 Started container nginx upgrade container # modify nginx.yamlimage: nginx:1.9.0# submitted to K8S# kubectl apply-f nginx.yaml to delete the container application [root@master01 ~] # kubectl delete-f nginx.yaml pod "nginx" deleted [root@master01 ~] # kubectl get podsNo resources found in default namespace.nginx.yaml parameter introduction parameter definition It is divided into two parts: metadata and Spec: the metadata store metadata Spec stores a unique definition of this object to describe the function it wants to express kind: Pod indicates that it is an API object of type Pod, which operates to manage the identity of another API object, the PodmetadataAPI object. That is, the Pod logo spec.containers indicates that it is a container-related parameter spec.hostAliases to add parsing to the container's / etc/hosts file to view the Pod help document [root@master01 ~] # kubectl explain Pod is how to publish the container to the K8S cluster. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.