我按如下方式编写了部署文件,这给出的错误是unknown field "platform"。你知道该指定什么才能基于架构进行部署吗?
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
platform:
architecture: amd64
os: linux
- name: nginx
image: ppc64le/nginx:1.7.9
ports:
- containerPort: 80
platform:
architecture: ppc64le
os: linux发布于 2018-05-18 14:31:06
您必须在您的部署规范上使用nodeAffinity定义。下面是我用来将任务绑定到amd64或arm主机的一个示例:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: beta.kubernetes.io/arch
operator: In
values:
- amd64您可以使用任意的键和值。这是documented example
发布于 2018-05-18 14:30:35
如果您查看specification of a container -没有为platform定义字段-那么您的错误与部署YAML中的错误有关。您必须从您的YAML中删除以下代码块才能使其工作(假设清单中没有其他问题):
platform:
architecture: ppc64le
os: linux其次,AFAIK,你想要做的事情是不可能的。我可以推荐两种方法作为替代方案:
- name: nginx image: nginx:{{ version }} ports: - containerPort: 80
一个
node & pod affinity can be found here的污点详情和tolerations documentation can be found here详情
发布于 2021-03-31 16:39:34
在导航模拟kubernetes集群状态的资源时,了解kubectl explain是很有用的。
因此,对于模板下的规范中的字段的描述,您可以运行以下命令
kubectl explain deployment.spec.template.spec并获取
KIND: Deployment
VERSION: apps/v1
RESOURCE: spec <Object>
DESCRIPTION:
Specification of the desired behavior of the pod. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
PodSpec is a description of a pod.
FIELDS:
activeDeadlineSeconds <integer>
Optional duration in seconds the pod may be active on the node relative to
StartTime before the system will actively try to mark it failed and kill
associated containers. Value must be a positive integer.
affinity <Object>
If specified, the pod's scheduling constraints
automountServiceAccountToken <boolean>
AutomountServiceAccountToken indicates whether a service account token
should be automatically mounted.
containers <[]Object> -required-
List of containers belonging to the pod. Containers cannot currently be
added or removed. There must be at least one container in a Pod. Cannot be
updated我已经剪掉了上面的输出,还有更多的东西要读。
如果您只想要字段名,请使用--recursive标志
kubectl explain deployment.spec.template.spec --recursive 输出的摘录...
podAffinity <Object>
preferredDuringSchedulingIgnoredDuringExecution <[]Object>
podAffinityTerm <Object>
labelSelector <Object>
matchExpressions <[]Object>
key <string>
operator <string>
values <[]string>
matchLabels <map[string]string>
namespaces <[]string>
topologyKey <string>
weight <integer>
requiredDuringSchedulingIgnoredDuringExecution <[]Object>
labelSelector <Object>
matchExpressions <[]Object>
key <string>
operator <string>
values <[]string>
matchLabels <map[string]string>
namespaces <[]string>
topologyKey <string> 上面的代码非常适合在命令行中使用。
在编辑器中,您可以使用YAML Language Server进行自动完成和验证。
https://stackoverflow.com/questions/50404503
复制相似问题