Skip to content

Commit

Permalink
Merge pull request #30 from wanjunlei/release-0.1
Browse files Browse the repository at this point in the history
add host local time to container
  • Loading branch information
Benjamin Huo authored Jul 21, 2020
2 parents 74202be + b030856 commit 91fab3e
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/notification-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func Main() int {
return 1
}

logger = log.With(logger, "ts", log.DefaultTimestampUTC)
logger = log.With(logger, "ts", log.DefaultTimestamp)
logger = log.With(logger, "caller", log.DefaultCaller)
_ = level.Info(logger).Log("msg", "Starting notification manager...", "addr", *listenAddress, "timeout", *webhookTimeout)

Expand Down
8 changes: 8 additions & 0 deletions config/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1940,5 +1940,13 @@ spec:
requests:
cpu: 100m
memory: 20Mi
volumeMounts:
- mountPath: /etc/localtime
name: host-time
serviceAccountName: notification-manager-sa
terminationGracePeriodSeconds: 10
volumes:
- hostPath:
path: /etc/localtime
type: ""
name: host-time
8 changes: 8 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,12 @@ spec:
requests:
cpu: 100m
memory: 20Mi
volumeMounts:
- mountPath: /etc/localtime
name: host-time
volumes:
- hostPath:
path: /etc/localtime
type: ""
name: host-time
terminationGracePeriodSeconds: 10
8 changes: 8 additions & 0 deletions helm/templates/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ spec:
name: notification-manager-operator
resources:
{{- toYaml .Values.operator.containers.operator.resources | nindent 10 }}
volumeMounts:
- mountPath: /etc/localtime
name: host-time
volumes:
- hostPath:
path: /etc/localtime
type: ""
name: host-time
serviceAccount: notification-manager-sa
serviceAccountName: notification-manager-sa
nodeSelector:
Expand Down
20 changes: 20 additions & 0 deletions pkg/controllers/notificationmanager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ func (r *NotificationManagerReconciler) mutateDeployment(deploy *appsv1.Deployme
},
},
},
VolumeMounts: []corev1.VolumeMount{
{
Name: "host-time",
MountPath: "/etc/localtime",
},
},
}

if len(nm.Spec.NotificationManagerNamespaces) > 0 {
Expand All @@ -217,6 +223,7 @@ func (r *NotificationManagerReconciler) mutateDeployment(deploy *appsv1.Deployme
deploy.Spec.Template.Spec.Containers[i].Ports = newC.Ports
deploy.Spec.Template.Spec.Containers[i].Command = newC.Command
deploy.Spec.Template.Spec.Containers[i].Env = newC.Env
deploy.Spec.Template.Spec.Containers[i].VolumeMounts = newC.VolumeMounts
break
}
}
Expand All @@ -226,6 +233,19 @@ func (r *NotificationManagerReconciler) mutateDeployment(deploy *appsv1.Deployme
deploy.Spec.Template.Spec.Containers = []corev1.Container{newC}
}

if len(deploy.Spec.Template.Spec.Volumes) == 0 {
deploy.Spec.Template.Spec.Volumes = []corev1.Volume{
{
Name: "host-time",
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: "/etc/localtime",
},
},
},
}
}

deploy.SetOwnerReferences(nil)
return ctrl.SetControllerReference(nm, deploy, r.Scheme)
}
Expand Down

0 comments on commit 91fab3e

Please sign in to comment.