Skip to content

Commit

Permalink
Add healthcheck configuration and RBAC in route agent and register crds
Browse files Browse the repository at this point in the history
Add the healthcheker configuration in route agent and give
permission for routegent permission for crud operation of
routeagent resources.

Register the routeagent crds

Signed-off-by: Aswin Suryanarayanan <[email protected]>
  • Loading branch information
aswinsuryan authored and tpantelis committed Jul 22, 2024
1 parent b96ec66 commit 37a9d80
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/rbac/submariner-diagnose/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ rules:
- nongatewayroutes
- servicediscoveries
- submariners
- routeagents
verbs:
- get
- list
Expand Down
10 changes: 10 additions & 0 deletions config/rbac/submariner-route-agent/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ rules:
- create
- update
- delete
- apiGroups:
- submariner.io
resources:
- routeagents
verbs:
- get
- list
- create
- update
- delete
15 changes: 15 additions & 0 deletions controllers/submariner/route_agent_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ func (r *Reconciler) reconcileRouteagentDaemonSet(ctx context.Context, instance
}

func newRouteAgentDaemonSet(cr *v1alpha1.Submariner, name string) *appsv1.DaemonSet {
// Default healthCheck Values
healthCheckEnabled := true
// The values are in seconds
healthCheckInterval := uint64(1)
healthCheckMaxPacketLossCount := uint64(5)

if cr.Spec.ConnectionHealthCheck != nil {
healthCheckEnabled = cr.Spec.ConnectionHealthCheck.Enabled
healthCheckInterval = cr.Spec.ConnectionHealthCheck.IntervalSeconds
healthCheckMaxPacketLossCount = cr.Spec.ConnectionHealthCheck.MaxPacketLossCount
}

labels := map[string]string{
"app": name,
"component": "routeagent",
Expand Down Expand Up @@ -142,6 +154,9 @@ func newRouteAgentDaemonSet(cr *v1alpha1.Submariner, name string) *appsv1.Daemon
FieldPath: "spec.nodeName",
},
}},
{Name: "SUBMARINER_HEALTHCHECKENABLED", Value: strconv.FormatBool(healthCheckEnabled)},
{Name: "SUBMARINER_HEALTHCHECKINTERVAL", Value: strconv.FormatUint(healthCheckInterval, 10)},
{Name: "SUBMARINER_HEALTHCHECKMAXPACKETLOSSCOUNT", Value: strconv.FormatUint(healthCheckMaxPacketLossCount, 10)},
}),
},
},
Expand Down
1 change: 1 addition & 0 deletions pkg/embeddedyamls/generators/yamls2go.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var files = []string{
"deploy/submariner/crds/submariner.io_globalingressips.yaml",
"deploy/submariner/crds/submariner.io_gatewayroutes.yaml",
"deploy/submariner/crds/submariner.io_nongatewayroutes.yaml",
"deploy/submariner/crds/submariner.io_routeagents.yaml",
"deploy/mcsapi/crds/multicluster.x_k8s.io_serviceexports.yaml",
"deploy/mcsapi/crds/multicluster.x_k8s.io_serviceimports.yaml",
"config/broker/broker-admin/service_account.yaml",
Expand Down
132 changes: 132 additions & 0 deletions pkg/embeddedyamls/yamls.go
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,127 @@ spec:
type: object
served: true
storage: true
`
Deploy_submariner_crds_submariner_io_routeagents_yaml = `---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
name: routeagents.submariner.io
spec:
group: submariner.io
names:
kind: RouteAgent
listKind: RouteAgentList
plural: routeagents
singular: routeagent
scope: Namespaced
versions:
- name: v1
schema:
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/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
status:
properties:
remoteEndpoints:
items:
properties:
latencyRTT:
description: |-
LatencySpec describes the round trip time information for a packet
between the gateway pods of two clusters.
properties:
average:
type: string
last:
type: string
max:
type: string
min:
type: string
stdDev:
type: string
type: object
spec:
properties:
backend:
type: string
backend_config:
additionalProperties:
type: string
type: object
cable_name:
type: string
cluster_id:
maxLength: 63
minLength: 1
type: string
healthCheckIP:
type: string
hostname:
type: string
nat_enabled:
type: boolean
private_ip:
type: string
public_ip:
type: string
subnets:
items:
type: string
type: array
required:
- backend
- cable_name
- cluster_id
- hostname
- nat_enabled
- private_ip
- public_ip
- subnets
type: object
status:
type: string
statusMessage:
type: string
required:
- spec
- status
- statusMessage
type: object
type: array
statusFailure:
type: string
version:
type: string
required:
- remoteEndpoints
- statusFailure
- version
type: object
required:
- status
type: object
served: true
storage: true
`
Deploy_mcsapi_crds_multicluster_x_k8s_io_serviceexports_yaml = `apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -3018,6 +3139,16 @@ rules:
- create
- update
- delete
- apiGroups:
- submariner.io
resources:
- routeagents
verbs:
- get
- list
- create
- update
- delete
`
Config_rbac_submariner_route_agent_role_binding_yaml = `---
kind: RoleBinding
Expand Down Expand Up @@ -3337,6 +3468,7 @@ rules:
- nongatewayroutes
- servicediscoveries
- submariners
- routeagents
verbs:
- get
- list
Expand Down
6 changes: 6 additions & 0 deletions pkg/gateway/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,11 @@ func Ensure(ctx context.Context, crdUpdater crd.Updater) error {
return errors.Wrap(err, "error getting non-Gateway routes")
}

_, err = crdUpdater.CreateOrUpdateFromEmbedded(ctx,
embeddedyamls.Deploy_submariner_crds_submariner_io_routeagents_yaml)
if err != nil && !apierrors.IsAlreadyExists(err) {
return errors.Wrap(err, "error getting Route Agent")
}

return nil
}

0 comments on commit 37a9d80

Please sign in to comment.