Kubernetes非常新。 过去
- 在 。
resources:
- my-app-service.yml
apiVersion: v1
kind: Service
metadata:
name: my-app-service
... etc.
- 从命令行中,我将运行以下内容:
kubectl apply -k /path/to/the/kustomization.yml
如果一切顺利 - boom - 我的群集上的服务运行。 Neato。
我现在正在尝试对某些内容进行故障排除,并想部署一个 我的群集上的图像,以便我可以进入其中并进行一些与网络/授权相关的测试。
这个想法是:
- 部署
- ssh,进行测试
- 删除容器/清洁
i labes k8s k8s不处理容器,因此我可能需要部署1个container pod或服务(在那里的区别不清楚),但是您明白了。
i 可以创建2个yaml文件,然后像我对其他所有事情一样在它们上运行 kubectl应用...
,但这感觉有些沉重。我想知道是否有一种更简单的方法可以从命令行中完成所有操作,而无需每次我想做这样的测试时都必须创建YAML文件。 有吗?
Very new to Kubernetes. In the past I've used kubectl
/Kustomize to deploy pods/services using the same repetitive pattern:
- On the file system, in my project, I'll have two YAML files such as
kustomization.yml
and my-app-service.yml
that look something like:
kustomization.yml
resources:
- my-app-service.yml
my-app-service.yml
apiVersion: v1
kind: Service
metadata:
name: my-app-service
... etc.
- From the command-line, I'll run something like the following:
kubectl apply -k /path/to/the/kustomization.yml
And if all goes well -- boom -- I've got the service running on my cluster. Neato.
I am now trying to troubleshoot something and want to deploy a single container of the google/cloud-sdk
image on my cluster, so that I can SSH into it and do some network/authorization-related testing.
The idea is:
- Deploy it
- SSH in, do my testing
- Delete the container/clean it up
I believe K8s doesn't deal with containers and so I'll probably need to deploy a 1-container pod or service (not clear on the difference there), but you get the idea.
I could just create 2 YAML files and run the kubectl apply ...
on them like I do for everything else, but that feels a bit heavy-handed. I'm wondering if there is an easier way to do this all from the command-line without having to create YAML files each time I want to do a test like this. Is there?
发布评论
评论(1)
您可以使用此命令创建一个带有给定图像的容器的POD:
如果您想在不编写YAML的情况下创建部署,则可以这样做:
您也可以仅生成YAML并将其保存为文件,然后使用<<代码> kubectl apply -f deployment.yaml ,以:
You can create a pod running a container with the given image with this command:
And if you want to create a Deployment without writing the Yaml, you can do:
You could also just generate the Yaml and save it to file, and then use
kubectl apply -f deployment.yaml
, generate it with: