具体来说,现有 Kubernetes 集群中有几个资源(当前用 定义YAML
),我想在构建过程中进行修改,还有一些我想从头开始创建。在每种情况下,我都希望在多个区域中这样做,以使所有区域保持同步。
有问题的资源是Agones fleets
,看起来像这样(实际值已删除,但具有代表性):
apiVersion: agones.dev/v1
kind: Fleet
metadata:
annotations:
agones.dev/sdk-version: 1.11.0
name: test
namespace: game-servers
resourceVersion: "12324578"
selfLink: /apis/agones.dev/v1/namespaces/game-servers/fleets/test
spec:
replicas: 1
scheduling: Packed
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
branch: test
git_commit: 1b12371827fdea31231230901876ffe
spec:
health:
disabled: false
failureThreshold: 5
initialDelaySeconds: 10
periodSeconds: 5
ports:
- containerPort: 1234
name: default
portPolicy: Dynamic
protocol: UDP
sdkServer:
logLevel: Info
template:
metadata:
creationTimestamp: null
labels:
role: game-servers
spec:
containers:
- image: registry.example.com/gameserver:1b12371827fdea31231230901876ffe
name: agones
resources:
limits:
cpu: 500m
memory: 512m
requests:
cpu: 100m
memory: 256Mi
nodeSelector:
role: game-servers
如果有现有的fleet
,我想将最新git commit
的注入标签以及要使用的图像(假设它将在注册表中适当地标记)。
如果没有现有的fleet
,对于某些值,我想循环并从头开始创建具有与上述相似特征的新车队。我尝试了几种不同的方法,但都失败了——从集群权限问题到尝试for
在 Jenkins/Groovy 中使用非常直接的循环时出现的奇怪错误。