Skip to content

Commit

Permalink
Fix stateful set template spec updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pdecat committed Dec 11, 2018
1 parent 761d3b4 commit 1a37e8c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
1 change: 0 additions & 1 deletion kubernetes/structures_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ func patchPodSpec(pathPrefix, prefix string, d *schema.ResourceData) (PatchOpera
ops := make([]PatchOperation, 0)

if d.HasChange(prefix + "active_deadline_seconds") {

v := d.Get(prefix + "active_deadline_seconds").(int)
ops = append(ops, &ReplaceOperation{
Path: pathPrefix + "/activeDeadlineSeconds",
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/structures_stateful_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func patchPodTemplateSpec(keyPrefix, pathPrefix string, d *schema.ResourceData)

if d.HasChange(keyPrefix + "spec") {
log.Printf("[TRACE] StatefulSet.Spec.Template.Spec has changes")
p, err := patchPodSpec(pathPrefix+"spec.0.", keyPrefix+"spec/", d)
p, err := patchPodSpec(pathPrefix+"spec", keyPrefix+"spec.0.", d)
if err != nil {
return ops, err
}
Expand Down
51 changes: 51 additions & 0 deletions test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
ports:
- port: 80
name: web
clusterIP: None
selector:
app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: "nginx"
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
imagePullPolicy: IfNotPresent
image: k8s.gcr.io/nginx-slim:0.8
env:
- name: test2
value: test2
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi

0 comments on commit 1a37e8c

Please sign in to comment.