Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/TektonConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,12 @@ There is a field called `options` available in all the components.<br>
> **NOTE:** There is a possibility to have two different values for a field.<br>
> An example: with a pre-defined field you can set value and the same field may be defined under `options` as well. In that case value from `options` will be final.

> **NOTE:** The embedded objects are not merged as a whole. The operator copies a
> known set of fields onto the manifest, and the per-kind lists below are
> exhaustive - a field outside them is ignored silently, with no error or warning.
> If a field you set under `options` has no effect, it is most likely not
> supported yet - please open an issue.

A sample `options` field,

```yaml
Expand Down Expand Up @@ -822,6 +828,11 @@ options:
custom-annotation: "foo"
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
template:
spec:
containers:
Expand All @@ -838,6 +849,10 @@ options:
custom-annotation: foo
spec:
replicas: 3
updateStrategy:
type: RollingUpdate
rollingUpdate:
partition: 1
template:
spec:
containers:
Expand Down Expand Up @@ -895,6 +910,7 @@ The following fields are supported in `deployment`
- `annotations` - supports add and update
- `spec`
- `replicas` - updates deployment replicas count
- `strategy` - replaces the existing deployment strategy with this, if `type` is not empty
- `template`
- `metadata`
- `labels` - supports add and update
Expand Down Expand Up @@ -929,6 +945,7 @@ The following fields are supported in `StatefulSet`
- `annotations` - supports add and update
- `spec`
- `replicas` - updates statefulSets replicas count
- `updateStrategy` - replaces the existing statefulSet update strategy with this, if `type` is not empty
- `serviceName` - updates service name
- `podManagementPolicy` - updates pod management policy
- `volumeClaimTemplates` - updates volume claim templates
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tekton-pipelines-controller
namespace: tekton-pipelines
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
selector:
matchLabels:
app.kubernetes.io/name: controller
template:
metadata:
labels:
app.kubernetes.io/name: controller
spec:
containers:
- name: tekton-pipelines-controller
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/controller:v0.50.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tekton-pipelines-controller
namespace: tekton-pipelines
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: controller
template:
metadata:
labels:
app.kubernetes.io/name: controller
spec:
containers:
- name: tekton-pipelines-controller
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/controller:v0.50.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: nginx
replicas: 2
updateStrategy:
type: RollingUpdate
rollingUpdate:
partition: 0
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: registry.k8s.io/nginx-slim:0.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tekton-pipelines-controller
namespace: tekton-pipelines
status: {}
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: controller
template:
metadata:
labels:
app.kubernetes.io/name: controller
spec:
containers:
- name: tekton-pipelines-controller
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/controller:v0.50.1
resources: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tekton-pipelines-controller
namespace: tekton-pipelines
status: {}
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/name: controller
template:
metadata:
labels:
app.kubernetes.io/name: controller
spec:
containers:
- name: tekton-pipelines-controller
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/controller:v0.50.1
resources: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
# The options asked for Recreate while also supplying a rollingUpdate block.
# The transformer passes both through untouched rather than silently dropping
# one of them; the API server is the component that rejects the combination.
apiVersion: apps/v1
kind: Deployment
metadata:
name: tekton-pipelines-controller
namespace: tekton-pipelines
status: {}
spec:
replicas: 1
strategy:
type: Recreate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/name: controller
template:
metadata:
labels:
app.kubernetes.io/name: controller
spec:
containers:
- name: tekton-pipelines-controller
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/controller:v0.50.1
resources: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tekton-pipelines-controller
namespace: tekton-pipelines
status: {}
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/name: controller
template:
metadata:
labels:
app.kubernetes.io/name: controller
spec:
containers:
- name: tekton-pipelines-controller
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/controller:v0.50.1
resources: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tekton-pipelines-controller
namespace: tekton-pipelines
status: {}
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
selector:
matchLabels:
app.kubernetes.io/name: controller
template:
metadata:
labels:
app.kubernetes.io/name: controller
spec:
containers:
- name: tekton-pipelines-controller
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/controller:v0.50.1
resources: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: nginx
replicas: 2
updateStrategy:
type: OnDelete
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: registry.k8s.io/nginx-slim:0.8
resources: {}
status:
availableReplicas: 0
replicas: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: nginx
replicas: 2
updateStrategy:
type: RollingUpdate
rollingUpdate:
partition: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: registry.k8s.io/nginx-slim:0.8
resources: {}
status:
availableReplicas: 0
replicas: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: nginx
replicas: 3
updateStrategy:
type: RollingUpdate
rollingUpdate:
partition: 0
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: registry.k8s.io/nginx-slim:0.8
resources: {}
status:
availableReplicas: 0
replicas: 0
18 changes: 18 additions & 0 deletions pkg/reconciler/common/transformer_additional_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,15 @@ func (ot *OptionsTransformer) updateDeployments(u *unstructured.Unstructured) er
targetDeployment.Spec.Replicas = ptr.Int32(*deploymentOptions.Spec.Replicas)
}

// update deployment strategy
// The whole struct is replaced instead of merged field by field: "rollingUpdate"
// may not be set when the type is "Recreate", so merging would leave the
// rollingUpdate block from the base manifest behind and the API server would
// reject the resulting deployment.
if deploymentOptions.Spec.Strategy.Type != "" {
targetDeployment.Spec.Strategy = deploymentOptions.Spec.Strategy
}

// update affinity
if deploymentOptions.Spec.Template.Spec.Affinity != nil {
targetDeployment.Spec.Template.Spec.Affinity = deploymentOptions.Spec.Template.Spec.Affinity
Expand Down Expand Up @@ -589,6 +598,15 @@ func (ot *OptionsTransformer) updateStatefulSets(u *unstructured.Unstructured) e
targetStatefulSet.Spec.Replicas = ptr.Int32(*statefulSetOptions.Spec.Replicas)
}

// update statefulSet update strategy
// The whole struct is replaced instead of merged field by field: "rollingUpdate"
// may not be set when the type is "OnDelete", so merging would leave the
// rollingUpdate block from the base manifest behind and the API server would
// reject the resulting statefulSet.
if statefulSetOptions.Spec.UpdateStrategy.Type != "" {
targetStatefulSet.Spec.UpdateStrategy = statefulSetOptions.Spec.UpdateStrategy
}

// update affinity
if statefulSetOptions.Spec.Template.Spec.Affinity != nil {
targetStatefulSet.Spec.Template.Spec.Affinity = statefulSetOptions.Spec.Template.Spec.Affinity
Expand Down
Loading
Loading