Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pod configuration #950

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/olm/main.go
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"time"

configclientset "github.com/openshift/client-go/config/clientset/versioned"
configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -158,6 +159,11 @@ func main() {
if err != nil {
log.Fatalf("error configuring client: %s", err.Error())
}
versionedConfigClient, err := configclientset.NewForConfig(config)
if err != nil {
err = fmt.Errorf("error configuring OpenShift Proxy client: %v", err)
return
}
configClient, err := configv1client.NewForConfig(config)
if err != nil {
log.Fatalf("error configuring client: %s", err.Error())
Expand All @@ -179,6 +185,7 @@ func main() {
olm.WithExternalClient(crClient),
olm.WithOperatorClient(opClient),
olm.WithRestConfig(config),
olm.WithConfigClient(versionedConfigClient),
)
if err != nil {
log.WithError(err).Fatalf("error configuring operator")
Expand Down
@@ -0,0 +1,96 @@
{{- if .Values.e2eLocalMode }}
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: "2019-07-08T17:25:44Z"
generation: 1
name: proxies.config.openshift.io
resourceVersion: "403"
selfLink: /apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/proxies.config.openshift.io
uid: 6af86a13-a1a5-11e9-b519-0a2c4a2d8fc8
spec:
conversion:
strategy: None
group: config.openshift.io
names:
kind: Proxy
listKind: ProxyList
plural: proxies
singular: proxy
scope: Cluster
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Spec holds user-settable values for the proxy configuration
properties:
httpProxy:
description: httpProxy is the URL of the proxy for HTTP requests. Empty
means unset and will not result in an env var.
type: string
httpsProxy:
description: httpsProxy is the URL of the proxy for HTTPS requests. Empty
means unset and will not result in an env var.
type: string
noProxy:
description: noProxy is a comma-separated list of hostnames and/or CIDRs
for which the proxy should not be used. Empty means unset and will
not result in an env var.
type: string
type: object
status:
description: status holds observed values from the cluster. They may not
be overridden.
properties:
httpProxy:
description: httpProxy is the URL of the proxy for HTTP requests.
type: string
httpsProxy:
description: httpsProxy is the URL of the proxy for HTTPS requests.
type: string
noProxy:
description: noProxy is a comma-separated list of hostnames and/or CIDRs
for which the proxy should not be used.
type: string
type: object
required:
- spec
version: v1
versions:
- name: v1
served: true
storage: true
status:
acceptedNames:
kind: Proxy
listKind: ProxyList
plural: proxies
singular: proxy
conditions:
- lastTransitionTime: "2019-07-08T17:25:44Z"
message: no conflicts found
reason: NoConflicts
status: "True"
type: NamesAccepted
- lastTransitionTime: null
message: the initial names have been accepted
reason: InitialNamesAccepted
status: "True"
type: Established
storedVersions:
- v1
{{- end }}
@@ -0,0 +1,10 @@
{{- if .Values.e2eLocalMode }}
apiVersion: config.openshift.io/v1
kind: Proxy
metadata:
name: cluster
spec:
httpProxy: "http://foo.com:8080"
httpsProxy: "https://foo.com:8080"
noProxy: "a,b,c"
{{- end }}
1 change: 1 addition & 0 deletions deploy/chart/values.yaml
Expand Up @@ -7,6 +7,7 @@ minKubeVersion: 1.11.0
writeStatusName: '""'
imagestream: false
debug: false
e2eLocalMode: false
installType: upstream
olm:
replicaCount: 1
Expand Down
40 changes: 40 additions & 0 deletions pkg/api/apis/operators/subscription_types.go
Expand Up @@ -33,6 +33,46 @@ type SubscriptionSpec struct {
Channel string
StartingCSV string
InstallPlanApproval Approval
Config SubscriptionConfig
}

// SubscriptionConfig contains configuration specified for a subscription.
type SubscriptionConfig struct {
// Label selector for pods. Existing ReplicaSets whose pods are
// selected by this will be the ones affected by this deployment.
// It must match the pod template's labels.
Selector *metav1.LabelSelector `json:"selector,omitempty"`

// NodeSelector is a selector which must be true for the pod to fit on a node.
// Selector which must match a node's labels for the pod to be scheduled on that node.
// More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// If specified, the pod's tolerations.
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// Compute Resources required by this container.
// Cannot be updated.
// More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// List of sources to populate environment variables in the container.
// The keys defined within a source must be a C_IDENTIFIER. All invalid keys
// will be reported as an event when the container is starting. When a key exists in multiple
// sources, the value associated with the last source will take precedence.
// Values defined by an Env with a duplicate key will take precedence.
// Cannot be updated.
// +optional
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
// List of environment variables to set in the container.
// Cannot be updated.
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
Env []corev1.EnvVar `json:"env,omitempty"`
}

// SubscriptionConditionType indicates an explicit state condition about a Subscription in "abnormal-true"
Expand Down
54 changes: 47 additions & 7 deletions pkg/api/apis/operators/v1alpha1/subscription_types.go
Expand Up @@ -29,12 +29,52 @@ const (

// SubscriptionSpec defines an Application that can be installed
type SubscriptionSpec struct {
CatalogSource string `json:"source"`
CatalogSourceNamespace string `json:"sourceNamespace"`
Package string `json:"name"`
Channel string `json:"channel,omitempty"`
StartingCSV string `json:"startingCSV,omitempty"`
InstallPlanApproval Approval `json:"installPlanApproval,omitempty"`
CatalogSource string `json:"source"`
CatalogSourceNamespace string `json:"sourceNamespace"`
Package string `json:"name"`
Channel string `json:"channel,omitempty"`
StartingCSV string `json:"startingCSV,omitempty"`
InstallPlanApproval Approval `json:"installPlanApproval,omitempty"`
Config SubscriptionConfig `json:"config,omitempty"`
}

// SubscriptionConfig contains configuration specified for a subscription.
type SubscriptionConfig struct {
// Label selector for pods. Existing ReplicaSets whose pods are
// selected by this will be the ones affected by this deployment.
// It must match the pod template's labels.
Selector *metav1.LabelSelector `json:"selector,omitempty"`

// NodeSelector is a selector which must be true for the pod to fit on a node.
// Selector which must match a node's labels for the pod to be scheduled on that node.
// More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// If specified, the pod's tolerations.
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// Compute Resources required by this container.
// Cannot be updated.
// More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// List of sources to populate environment variables in the container.
// The keys defined within a source must be a C_IDENTIFIER. All invalid keys
// will be reported as an event when the container is starting. When a key exists in multiple
// sources, the value associated with the last source will take precedence.
// Values defined by an Env with a duplicate key will take precedence.
// Cannot be updated.
// +optional
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
// List of environment variables to set in the container.
// Cannot be updated.
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
Env []corev1.EnvVar `json:"env,omitempty"`
}

// SubscriptionConditionType indicates an explicit state condition about a Subscription in "abnormal-true"
Expand Down Expand Up @@ -81,7 +121,7 @@ const (
InstallPlanNotYetReconciled = "InstallPlanNotYetReconciled"

// InstallPlanFailed is a reason string for Subscriptions that transitioned due to a referenced InstallPlan failing without setting an explicit failure condition.
InstallPlanFailed = "InstallPlanFailed"
InstallPlanFailed = "InstallPlanFailed"
)

// SubscriptionCondition represents the latest available observations of a Subscription's state.
Expand Down
46 changes: 46 additions & 0 deletions pkg/api/apis/operators/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.