Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Kolesnik <[email protected]>
  • Loading branch information
vthapar and mkolesnik authored Aug 24, 2022
1 parent 9c3fcce commit b964167
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
2 changes: 1 addition & 1 deletion controllers/submariner/gateway_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func newGatewayPodTemplate(cr *v1alpha1.Submariner, name string, podSelectorLabe
{Name: "SUBMARINER_HEALTHCHECKENABLED", Value: strconv.FormatBool(healthCheckEnabled)},
{Name: "SUBMARINER_HEALTHCHECKINTERVAL", Value: strconv.FormatUint(healthCheckInterval, 10)},
{Name: "SUBMARINER_HEALTHCHECKMAXPACKETLOSSCOUNT", Value: strconv.FormatUint(healthCheckMaxPacketLossCount, 10)},
{Name: "SUBMARINER_GWMETRICSPORT", Value: constants.MetricsGWPort},
{Name: "SUBMARINER_METRICS_PORT", Value: constants.MetricsGWPort},
{Name: "NODE_NAME", ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "spec.nodeName",
Expand Down
2 changes: 1 addition & 1 deletion controllers/submariner/globalnet_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func newGlobalnetDaemonSet(cr *v1alpha1.Submariner, name string) *appsv1.DaemonS
{Name: "SUBMARINER_NAMESPACE", Value: cr.Spec.Namespace},
{Name: "SUBMARINER_CLUSTERID", Value: cr.Spec.ClusterID},
{Name: "SUBMARINER_EXCLUDENS", Value: "submariner-operator,kube-system,operators,openshift-monitoring,openshift-dns"},
{Name: "SUBMARINER_GNMETRICSPORT", Value: constants.MetricsGNPort},
{Name: "SUBMARINER_METRICS_PORT", Value: constants.MetricsGNPort},
{Name: "NODE_NAME", ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "spec.nodeName",
Expand Down
50 changes: 20 additions & 30 deletions controllers/submariner/metrics_proxy_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,7 @@ func newMetricsProxyDaemonSet(cr *v1alpha1.Submariner, name string) *appsv1.Daem
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "gateway-metrics-proxy",
Image: getImagePath(cr, names.MetricsProxyImage, names.MetricsProxyComponent),
ImagePullPolicy: helpers.GetPullPolicy(cr.Spec.Version, cr.Spec.ImageOverrides[names.MetricsProxyComponent]),
Env: []corev1.EnvVar{
{Name: "NODE_IP", ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "status.hostIP",
},
}},
},
Command: []string{"/usr/bin/nc"},
Args: []string{"-v", "-lk", "-p", fmt.Sprint(gatewayMetricsServerPort), "-e", "nc", "$(NODE_IP)", constants.MetricsGWPort},
},
*metricProxyContainer(cr, "gateway-metrics-proxy", gatewayMetricsServerPort, constants.MetricsGWPort),
},
NodeSelector: map[string]string{"submariner.io/gateway": "true"},
// The MetricsProxy Pod must be able to run on any flagged node, regardless of existing taints
Expand All @@ -85,23 +72,26 @@ func newMetricsProxyDaemonSet(cr *v1alpha1.Submariner, name string) *appsv1.Daem
}

if cr.Spec.GlobalCIDR != "" {
gnContainer := corev1.Container{
Name: "globalnet-metrics-proxy",
Image: getImagePath(cr, names.MetricsProxyImage, names.MetricsProxyComponent),
ImagePullPolicy: helpers.GetPullPolicy(cr.Spec.Version, cr.Spec.ImageOverrides[names.MetricsProxyComponent]),
Env: []corev1.EnvVar{
{Name: "NODE_IP", ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "status.hostIP",
},
}},
},
Command: []string{"/usr/bin/nc"},
Args: []string{"-v", "-lk", "-p", fmt.Sprint(globalnetMetricsServerPort), "-e", "nc", "$(NODE_IP)", constants.MetricsGNPort},
}

daemonSet.Spec.Template.Spec.Containers = append(daemonSet.Spec.Template.Spec.Containers, gnContainer)
daemonSet.Spec.Template.Spec.Containers = append(daemonSet.Spec.Template.Spec.Containers,
*metricProxyContainer(cr, "globalnet-metrics-proxy", globalnetMetricsServerPort, constants.MetricsGNPort))
}

return daemonSet
}

func metricProxyContainer(cr *v1alpha1.Submariner, name string, hostPort, podPort int) *corev1.Container {
return &corev1.Container{
Name: name,
Image: getImagePath(cr, names.MetricsProxyImage, names.MetricsProxyComponent),
ImagePullPolicy: helpers.GetPullPolicy(cr.Spec.Version, cr.Spec.ImageOverrides[names.MetricsProxyComponent]),
Env: []corev1.EnvVar{
{Name: "NODE_IP", ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "status.hostIP",
},
}},
},
Command: []string{"/usr/bin/nc"},
Args: []string{"-v", "-lk", "-p", fmt.Sprint(hostPort), "-e", "nc", "$(NODE_IP)", fmt.Sprint(podPort)},
}
}

0 comments on commit b964167

Please sign in to comment.