Skip to content

Commit

Permalink
Merge pull request #119 from liqlin2015/master
Browse files Browse the repository at this point in the history
Watch managed resources
  • Loading branch information
liqlin2015 authored Sep 22, 2020
2 parents 0d1a564 + 0a9bc39 commit 0e5d670
Show file tree
Hide file tree
Showing 8 changed files with 851 additions and 50 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: managementingresses.operator.ibm.com
labels:
app.kubernetes.io/name: ibm-management-ingress-operator
app.kubernetes.io/instance: ibm-management-ingress-operator
app.kubernetes.io/managed-by: ibm-management-ingress-operator
spec:
group: operator.ibm.com
names:
kind: ManagementIngress
listKind: ManagementIngressList
plural: managementingresses
singular: managementingress
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: ManagementIngress is the Schema for the managementingresses API
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/sig-architecture/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/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ManagementIngressSpec defines the desired state of ManagementIngress
properties:
allowedHostHeader:
type: string
cert:
properties:
dnsNames:
items:
type: string
type: array
ipAddresses:
items:
type: string
type: array
issuer:
properties:
kind:
type: string
name:
type: string
required:
- kind
- name
type: object
repository:
type: string
required:
- issuer
type: object
config:
additionalProperties:
type: string
type: object
fipsEnabled:
type: boolean
image:
properties:
repository:
type: string
tag:
type: string
type: object
imageRegistry:
type: string
managementState:
type: string
nodeSelector:
additionalProperties:
type: string
type: object
resources:
description: ResourceRequirements describes the compute resource requirements.
properties:
limits:
additionalProperties:
type: string
description: 'Limits describes the maximum amount of compute resources
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
requests:
additionalProperties:
type: string
description: 'Requests describes the minimum amount of compute resources
required. If Requests is omitted for a container, it defaults
to Limits if that is explicitly specified, otherwise to an implementation-defined
value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
routeHost:
type: string
tolerations:
items:
description: The pod this Toleration is attached to tolerates any
taint that matches the triple <key,value,effect> using the matching
operator <operator>.
properties:
effect:
description: Effect indicates the taint effect to match. Empty
means match all taint effects. When specified, allowed values
are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Key is the taint key that the toleration applies
to. Empty means match all taint keys. If the key is empty, operator
must be Exists; this combination means to match all values and
all keys.
type: string
operator:
description: Operator represents a key's relationship to the value.
Valid operators are Exists and Equal. Defaults to Equal. Exists
is equivalent to wildcard for value, so that a pod can tolerate
all taints of a particular category.
type: string
tolerationSeconds:
description: TolerationSeconds represents the period of time the
toleration (which must be of effect NoExecute, otherwise this
field is ignored) tolerates the taint. By default, it is not
set, which means tolerate the taint forever (do not evict).
Zero and negative values will be treated as 0 (evict immediately)
by the system.
format: int64
type: integer
value:
description: Value is the taint value the toleration matches to.
If the operator is Exists, the value should be empty, otherwise
just a regular string.
type: string
type: object
type: array
required:
- cert
- imageRegistry
- managementState
- routeHost
type: object
status:
description: ManagementIngressStatus defines the observed state of ManagementIngress
properties:
condition:
additionalProperties:
items:
properties:
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
type: object
host:
type: string
operandState:
properties:
message:
type: string
status:
type: string
required:
- message
- status
type: object
podstate:
additionalProperties:
items:
type: string
type: array
type: object
required:
- host
- operandState
- podstate
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
channels:
- currentCSV: ibm-management-ingress-operator.v1.3.2
- currentCSV: ibm-management-ingress-operator.v1.3.3
name: dev
- currentCSV: ibm-management-ingress-operator.v1.3.2
- currentCSV: ibm-management-ingress-operator.v1.3.3
name: beta
- currentCSV: ibm-management-ingress-operator.v1.2.1
name: stable-v1
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/managementingress/handler/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ func patchOrCreateConfigmap(ingr *IngressRequest, cm *core.ConfigMap) error {
if errors.IsNotFound(err) {
// create configmap
klog.Infof("Creating Configmap: %s for %q.", cm.ObjectMeta.Name, ingr.managementIngress.Name)

if err = controllerutil.SetControllerReference(ingr.managementIngress, cm, ingr.scheme); err != nil {
klog.Errorf("Error setting controller reference on Configmap: %v", err)
}
err = ingr.Create(cm)
if err != nil {
ingr.recorder.Eventf(ingr.managementIngress, "Warning", "CreatedConfigmap", "Failure creating configmap %q: %v", cm.ObjectMeta.Name, err)
return fmt.Errorf("Failure creating configmap: %v", err)
}

} else {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/controller/managementingress/handler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ func Reconcile(ingressRequest *IngressRequest) (err error) {
}

// create serviceAccount
if err = ingressRequest.CreateServiceAccount(); err != nil {
return fmt.Errorf("Unable to create serviceAccount for %q: %v", ingressRequest.managementIngress.Name, err)
}
// if err = ingressRequest.CreateServiceAccount(); err != nil {
// return fmt.Errorf("Unable to create serviceAccount for %q: %v", ingressRequest.managementIngress.Name, err)
// }

// create scc
if err = ingressRequest.CreateSecurityContextConstraint(); err != nil {
return fmt.Errorf("Unable to create SecurityContextConstraint for %q: %v", ingressRequest.managementIngress.Name, err)
}
// if err = ingressRequest.CreateSecurityContextConstraint(); err != nil {
// return fmt.Errorf("Unable to create SecurityContextConstraint for %q: %v", ingressRequest.managementIngress.Name, err)
// }

// Reconcile service
if err = ingressRequest.CreateOrUpdateService(); err != nil {
Expand Down
5 changes: 4 additions & 1 deletion pkg/controller/managementingress/handler/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"k8s.io/klog"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)

//NewRoute stubs an instance of a Route
Expand Down Expand Up @@ -86,6 +86,9 @@ func (ingressRequest *IngressRequest) createOrUpdateSecret(secretName, namespace
clusterSecret := NewSecret(secretName, namespace, caCert)

klog.Infof("create secret: %s for %q.", secretName, ingressRequest.managementIngress.ObjectMeta.Name)
if err := controllerutil.SetControllerReference(ingressRequest.managementIngress, clusterSecret, ingressRequest.scheme); err != nil {
klog.Errorf("Error setting controller reference on Secret: %v", err)
}
err := ingressRequest.Create(clusterSecret)
if err != nil {
if !errors.IsAlreadyExists(err) {
Expand Down
Loading

0 comments on commit 0e5d670

Please sign in to comment.