16.5. 在 Outpost 中创建用户工作负载
将 AWS VPC 集群中的 OpenShift Container Platform 扩展为 Outpost 后,您可以使用带有标签 node-role.kubernetes.io/outposts
的边缘计算节点在 Outpost 中创建用户工作负载。
先决条件
- 您已将 AWS VPC 集群扩展到 Outpost。
-
您可以使用具有
cluster-admin
权限的账户访问集群。 -
已安装 OpenShift CLI(
oc
)。 - 您已创建了部署与 Outpost 环境兼容的边缘计算机器的计算机器集。
流程
为您要部署到边缘子网中边缘计算节点的应用程序配置
Deployment
资源文件。Deployment
清单示例kind: Namespace apiVersion: v1 metadata: name: <application_name> 1 --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: <application_name> namespace: <application_namespace> 2 spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: gp2-csi 3 volumeMode: Filesystem --- apiVersion: apps/v1 kind: Deployment metadata: name: <application_name> namespace: <application_namespace> spec: selector: matchLabels: app: <application_name> replicas: 1 template: metadata: labels: app: <application_name> location: outposts 4 spec: securityContext: seccompProfile: type: RuntimeDefault nodeSelector: 5 node-role.kubernetes.io/outpost: '' tolerations: 6 - key: "node-role.kubernetes.io/outposts" operator: "Equal" value: "" effect: "NoSchedule" containers: - image: openshift/origin-node command: - "/bin/socat" args: - TCP4-LISTEN:8080,reuseaddr,fork - EXEC:'/bin/bash -c \"printf \\\"HTTP/1.0 200 OK\r\n\r\n\\\"; sed -e \\\"/^\r/q\\\"\"' imagePullPolicy: Always name: <application_name> ports: - containerPort: 8080 volumeMounts: - mountPath: "/mnt/storage" name: data volumes: - name: data persistentVolumeClaim: claimName: <application_name>
运行以下命令来创建
Deployment
资源:$ oc create -f <application_deployment>.yaml
配置
Service
对象,将 pod 从目标边缘计算节点公开到在边缘网络中运行的服务。Service
清单示例apiVersion: v1 kind: Service 1 metadata: name: <application_name> namespace: <application_namespace> spec: ports: - port: 80 targetPort: 8080 protocol: TCP type: NodePort selector: 2 app: <application_name>
运行以下命令来创建
Service
CR:$ oc create -f <application_service>.yaml