Skip to content

Commit

Permalink
Merge pull request #955 from jpeeler/set-resource-requests
Browse files Browse the repository at this point in the history
feat(deploy): add resource requests to all pods
  • Loading branch information
openshift-merge-robot authored Jul 20, 2019
2 parents a81dc5f + 4e41b8d commit bb4e018
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 140 deletions.
4 changes: 4 additions & 0 deletions deploy/chart/templates/_packageserver.deployment-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ spec:
path: /healthz
port: {{ .Values.package.service.internalPort }}
terminationMessagePolicy: FallbackToLogsOnError
{{- if .Values.package.resources }}
resources:
{{ toYaml .Values.package.resources | indent 10 }}
{{- end}}
{{- end -}}
12 changes: 12 additions & 0 deletions deploy/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ olm:
internalPort: 8080
nodeSelector:
beta.kubernetes.io/os: linux
resources:
requests:
cpu: 10m
memory: 160Mi

catalog:
replicaCount: 1
Expand All @@ -29,6 +33,10 @@ catalog:
internalPort: 8080
nodeSelector:
beta.kubernetes.io/os: linux
resources:
requests:
cpu: 10m
memory: 80Mi

package:
replicaCount: 2
Expand All @@ -39,3 +47,7 @@ package:
internalPort: 5443
nodeSelector:
beta.kubernetes.io/os: linux
resources:
requests:
cpu: 10m
memory: 50Mi
12 changes: 12 additions & 0 deletions deploy/ocp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ olm:
tolerationSeconds: 120
tlsCertPath: /var/run/secrets/serving-cert/tls.crt
tlsKeyPath: /var/run/secrets/serving-cert/tls.key
resources:
requests:
cpu: 10m
memory: 160Mi
catalog:
replicaCount: 1
image:
Expand All @@ -53,6 +57,10 @@ catalog:
operator: Exists
effect: NoExecute
tolerationSeconds: 120
resources:
requests:
cpu: 10m
memory: 80Mi
package:
replicaCount: 2
image:
Expand All @@ -75,3 +83,7 @@ package:
operator: Exists
effect: NoExecute
tolerationSeconds: 120
resources:
requests:
cpu: 10m
memory: 50Mi
5 changes: 5 additions & 0 deletions manifests/0000_50_olm_07-olm-operator.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ spec:
fieldPath: metadata.namespace
- name: OPERATOR_NAME
value: olm-operator
resources:
requests:
cpu: 10m
memory: 160Mi


volumeMounts:
- mountPath: /var/run/secrets/serving-cert
Expand Down
5 changes: 5 additions & 0 deletions manifests/0000_50_olm_08-catalog-operator.deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ spec:
- name: RELEASE_VERSION
value: "0.0.1-snapshot"

resources:
requests:
cpu: 10m
memory: 80Mi


volumeMounts:
- mountPath: /var/run/secrets/serving-cert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ spec:
path: /healthz
port: 5443
terminationMessagePolicy: FallbackToLogsOnError
resources:
requests:
cpu: 10m
memory: 50Mi

maturity: alpha
version: 0.10.1
apiservicedefinitions:
Expand Down
67 changes: 13 additions & 54 deletions pkg/controller/operators/catalog/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,23 +228,23 @@ func TestExecutePlan(t *testing.T) {
Resource: v1alpha1.StepResource{
CatalogSource: "catalog",
CatalogSourceNamespace: namespace,
Group: "",
Version: "v1",
Kind: "Service",
Name: "service",
Manifest: toManifest(service("service", namespace)),
Group: "",
Version: "v1",
Kind: "Service",
Name: "service",
Manifest: toManifest(service("service", namespace)),
},
Status: v1alpha1.StepStatusUnknown,
},
{
Resource: v1alpha1.StepResource{
CatalogSource: "catalog",
CatalogSourceNamespace: namespace,
Group: "operators.coreos.com",
Version: "v1alpha1",
Kind: "ClusterServiceVersion",
Name: "csv",
Manifest: toManifest(csv("csv", namespace, nil, nil)),
Group: "operators.coreos.com",
Version: "v1alpha1",
Kind: "ClusterServiceVersion",
Name: "csv",
Manifest: toManifest(csv("csv", namespace, nil, nil)),
},
Status: v1alpha1.StepStatusUnknown,
},
Expand Down Expand Up @@ -317,6 +317,7 @@ func TestSyncCatalogSources(t *testing.T) {
Name: "cool-catalog",
Namespace: "cool-namespace",
UID: types.UID("catalog-uid"),
Labels: map[string]string{"olm.catalogSource": "cool-catalog"},
},
Spec: v1alpha1.CatalogSourceSpec{
Image: "catalog-image",
Expand Down Expand Up @@ -480,6 +481,7 @@ func TestSyncCatalogSources(t *testing.T) {
Name: "cool-catalog",
Namespace: "cool-namespace",
UID: types.UID("catalog-uid"),
Labels: map[string]string{"olm.catalogSource": "cool-catalog"},
},
Spec: v1alpha1.CatalogSourceSpec{
Image: "old-image",
Expand Down Expand Up @@ -885,50 +887,7 @@ func toManifest(obj runtime.Object) string {
}

func pod(s v1alpha1.CatalogSource) *corev1.Pod {
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
GenerateName: s.GetName() + "-",
Namespace: s.GetNamespace(),
Labels: map[string]string{
"olm.catalogSource": s.GetName(),
},
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "registry-server",
Image: s.Spec.Image,
Ports: []corev1.ContainerPort{
{
Name: "grpc",
ContainerPort: 50051,
},
},
ReadinessProbe: &corev1.Probe{
Handler: corev1.Handler{
Exec: &corev1.ExecAction{
Command: []string{"grpc_health_probe", "-addr=localhost:50051"},
},
},
InitialDelaySeconds: 5,
},
LivenessProbe: &corev1.Probe{
Handler: corev1.Handler{
Exec: &corev1.ExecAction{
Command: []string{"grpc_health_probe", "-addr=localhost:50051"},
},
},
InitialDelaySeconds: 10,
},
},
},
Tolerations: []corev1.Toleration{
{
Operator: corev1.TolerationOpExists,
},
},
},
}
pod := reconciler.Pod(&s, "registry-server", s.Spec.Image, s.GetLabels(), 5, 10)
ownerutil.AddOwner(pod, &s, false, false)
return pod
}
47 changes: 3 additions & 44 deletions pkg/controller/registry/reconciler/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,50 +89,9 @@ func (s *configMapCatalogSourceDecorator) Service() *v1.Service {
}

func (s *configMapCatalogSourceDecorator) Pod(image string) *v1.Pod {
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
GenerateName: s.GetName() + "-",
Namespace: s.GetNamespace(),
Labels: s.Labels(),
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "configmap-registry-server",
Image: image,
Command: []string{"configmap-server", "-c", s.Spec.ConfigMap, "-n", s.GetNamespace()},
Ports: []v1.ContainerPort{
{
Name: "grpc",
ContainerPort: 50051,
},
},
ReadinessProbe: &v1.Probe{
Handler: v1.Handler{
Exec: &v1.ExecAction{
Command: []string{"grpc_health_probe", "-addr=localhost:50051"},
},
},
InitialDelaySeconds: 1,
},
LivenessProbe: &v1.Probe{
Handler: v1.Handler{
Exec: &v1.ExecAction{
Command: []string{"grpc_health_probe", "-addr=localhost:50051"},
},
},
InitialDelaySeconds: 2,
},
},
},
Tolerations: []v1.Toleration{
{
Operator: v1.TolerationOpExists,
},
},
ServiceAccountName: s.GetName() + ConfigMapServerPostfix,
},
}
pod := Pod(s.CatalogSource, "configmap-registry-server", image, s.Labels(), 1, 2)
pod.Spec.ServiceAccountName = s.GetName() + ConfigMapServerPostfix
pod.Spec.Containers[0].Command = []string{"configmap-server", "-c", s.Spec.ConfigMap, "-n", s.GetNamespace()}
ownerutil.AddOwner(pod, s.CatalogSource, false, false)
return pod
}
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/registry/reconciler/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func validConfigMapCatalogSource(configMap *corev1.ConfigMap) *v1alpha1.CatalogS
Name: "cool-catalog",
Namespace: testNamespace,
UID: types.UID("catalog-uid"),
Labels: map[string]string{"olm.catalogSource": "cool-catalog"},
},
Spec: v1alpha1.CatalogSourceSpec{
ConfigMap: "cool-configmap",
Expand Down
43 changes: 1 addition & 42 deletions pkg/controller/registry/reconciler/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,48 +55,7 @@ func (s *grpcCatalogSourceDecorator) Service() *v1.Service {
}

func (s *grpcCatalogSourceDecorator) Pod() *v1.Pod {
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
GenerateName: s.GetName() + "-",
Namespace: s.GetNamespace(),
Labels: s.Labels(),
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "registry-server",
Image: s.Spec.Image,
Ports: []v1.ContainerPort{
{
Name: "grpc",
ContainerPort: 50051,
},
},
ReadinessProbe: &v1.Probe{
Handler: v1.Handler{
Exec: &v1.ExecAction{
Command: []string{"grpc_health_probe", "-addr=localhost:50051"},
},
},
InitialDelaySeconds: 5,
},
LivenessProbe: &v1.Probe{
Handler: v1.Handler{
Exec: &v1.ExecAction{
Command: []string{"grpc_health_probe", "-addr=localhost:50051"},
},
},
InitialDelaySeconds: 10,
},
},
},
Tolerations: []v1.Toleration{
{
Operator: v1.TolerationOpExists,
},
},
},
}
pod := Pod(s.CatalogSource, "registry-server", s.Spec.Image, s.Labels(), 5, 10)
ownerutil.AddOwner(pod, s.CatalogSource, false, false)
return pod
}
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/registry/reconciler/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func validGrpcCatalogSource(image, address string) *v1alpha1.CatalogSource {
Name: "img-catalog",
Namespace: testNamespace,
UID: types.UID("catalog-uid"),
Labels: map[string]string{"olm.catalogSource": "img-catalog"},
},
Spec: v1alpha1.CatalogSourceSpec{
Image: image,
Expand Down
54 changes: 54 additions & 0 deletions pkg/controller/registry/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
package reconciler

import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1"
Expand Down Expand Up @@ -83,3 +85,55 @@ func NewRegistryReconcilerFactory(lister operatorlister.OperatorLister, opClient
ConfigMapServerImage: configMapServerImage,
}
}

func Pod(source *v1alpha1.CatalogSource, name string, image string, labels map[string]string, readinessDelay int32, livenessDelay int32) *v1.Pod {
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
GenerateName: source.GetName() + "-",
Namespace: source.GetNamespace(),
Labels: labels,
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: name,
Image: image,
Ports: []v1.ContainerPort{
{
Name: "grpc",
ContainerPort: 50051,
},
},
ReadinessProbe: &v1.Probe{
Handler: v1.Handler{
Exec: &v1.ExecAction{
Command: []string{"grpc_health_probe", "-addr=localhost:50051"},
},
},
InitialDelaySeconds: readinessDelay,
},
LivenessProbe: &v1.Probe{
Handler: v1.Handler{
Exec: &v1.ExecAction{
Command: []string{"grpc_health_probe", "-addr=localhost:50051"},
},
},
InitialDelaySeconds: livenessDelay,
},
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("10m"),
v1.ResourceMemory: resource.MustParse("50Mi"),
},
},
},
},
Tolerations: []v1.Toleration{
{
Operator: v1.TolerationOpExists,
},
},
},
}
return pod
}

0 comments on commit bb4e018

Please sign in to comment.