-
Notifications
You must be signed in to change notification settings - Fork 230
USHIFT-6797: C2CC Probe remote clusters #6729
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e493156
RemoteCluster: status fields for healthcheck probing
pmtk c596242
Implement healthcheck probe loop
pmtk 843ece3
Register c2cc-probe subcommand
pmtk fc2982d
Add probe pod asset manifests
pmtk 40acac6
Deploy probe pod assets from C2CC controller
pmtk 862a6a4
Clean up probe resources when C2CC is disabled
pmtk c3b836d
Reconcile probe deployment on every cycle
pmtk 2b99267
Add Robot Framework tests for C2CC probe deployment
pmtk 29cac40
Fix probe restart loop caused by status-only updates
pmtk a3940a8
Extract Compute 11th IP keyword to shared c2cc resource
pmtk 91459d8
Apply CodeRabbit suggestions from PR #6729
pmtk 5464cf0
Fix golangci-lint findings
pmtk d61e5fa
Change the namespace to openshift-c2cc
pmtk f42d208
Reuse stopProbe
pmtk 81b1403
Retry status update
pmtk ae07f59
Add negative test case
pmtk 912f38b
Check all remotestatus CRs
pmtk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: microshift-c2cc-probe | ||
| rules: | ||
| - apiGroups: | ||
| - microshift.io | ||
| resources: | ||
| - remoteclusters | ||
| verbs: | ||
| - get | ||
| - list | ||
| - watch | ||
| - apiGroups: | ||
| - microshift.io | ||
| resources: | ||
| - remoteclusters/status | ||
| verbs: | ||
| - update | ||
| - patch | ||
| - apiGroups: | ||
| - security.openshift.io | ||
| resources: | ||
| - securitycontextconstraints | ||
| verbs: | ||
| - use | ||
| resourceNames: | ||
| - privileged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: microshift-c2cc-probe | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: microshift-c2cc-probe | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| namespace: openshift-c2cc | ||
| name: c2cc-probe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| namespace: openshift-c2cc | ||
| name: c2cc-probe | ||
| labels: | ||
| app: c2cc-probe | ||
| spec: | ||
| replicas: 1 | ||
| strategy: | ||
| type: Recreate | ||
| selector: | ||
| matchLabels: | ||
| app: c2cc-probe | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: c2cc-probe | ||
| annotations: | ||
| target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}' | ||
| openshift.io/required-scc: privileged | ||
| spec: | ||
| serviceAccountName: c2cc-probe | ||
| containers: | ||
| - name: c2cc-probe | ||
| image: '{{ .ReleaseImage.cli }}' | ||
| imagePullPolicy: IfNotPresent | ||
| command: | ||
| - /host/usr/bin/microshift | ||
| - c2cc-probe | ||
| ports: | ||
| - containerPort: 8080 | ||
| name: probe | ||
| protocol: TCP | ||
| livenessProbe: | ||
| httpGet: | ||
| path: / | ||
| port: 8080 | ||
| initialDelaySeconds: 10 | ||
| periodSeconds: 10 | ||
| resources: | ||
| requests: | ||
| cpu: 50m | ||
| memory: 64Mi | ||
| volumeMounts: | ||
| - name: microshift-binary | ||
| mountPath: /host/usr/bin/microshift | ||
| readOnly: true | ||
| volumes: | ||
| - name: microshift-binary | ||
| hostPath: | ||
| path: /usr/bin/microshift | ||
| type: File | ||
| nodeSelector: | ||
| node-role.kubernetes.io/master: "" | ||
| priorityClassName: system-cluster-critical | ||
| tolerations: | ||
| - key: node-role.kubernetes.io/master | ||
| operator: Exists | ||
| effect: NoSchedule | ||
|
pmtk marked this conversation as resolved.
|
||
| - key: node.kubernetes.io/unreachable | ||
| operator: Exists | ||
| effect: NoExecute | ||
| tolerationSeconds: 120 | ||
| - key: node.kubernetes.io/not-ready | ||
| operator: Exists | ||
| effect: NoExecute | ||
| tolerationSeconds: 120 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| apiVersion: v1 | ||
| kind: Namespace | ||
| metadata: | ||
| name: openshift-c2cc | ||
| labels: | ||
| pod-security.kubernetes.io/enforce: privileged | ||
| pod-security.kubernetes.io/audit: privileged | ||
| pod-security.kubernetes.io/warn: privileged | ||
| annotations: | ||
| openshift.io/node-selector: "" | ||
| workload.openshift.io/allowed: "management" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| namespace: openshift-c2cc | ||
| name: c2cc-probe | ||
| spec: | ||
| clusterIP: '{{ .ProbeServiceClusterIP }}' | ||
| ports: | ||
| - name: probe | ||
| port: 8080 | ||
| targetPort: 8080 | ||
| protocol: TCP | ||
| selector: | ||
| app: c2cc-probe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| namespace: openshift-c2cc | ||
| name: c2cc-probe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "github.com/openshift/microshift/pkg/controllers/c2cc" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func NewC2CCProbeCommand() *cobra.Command { | ||
| return &cobra.Command{ | ||
| Use: "c2cc-probe", | ||
| Short: "Run C2CC remote cluster probe (designed to run as a pod)", | ||
| Hidden: true, | ||
| RunE: func(cmd *cobra.Command, _ []string) error { | ||
| return c2cc.RunProbe(cmd.Context()) | ||
| }, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package c2cc | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "fmt" | ||
| "net" | ||
| "text/template" | ||
|
|
||
| "github.com/apparentlymart/go-cidr/cidr" | ||
| "github.com/openshift/microshift/pkg/assets" | ||
| "github.com/openshift/microshift/pkg/release" | ||
| "k8s.io/klog/v2" | ||
| ) | ||
|
|
||
| var ( | ||
| c2ccNamespace = []string{"components/c2cc/namespace.yaml"} | ||
| c2ccServiceAccount = []string{"components/c2cc/serviceaccount.yaml"} | ||
| c2ccClusterRole = []string{"components/c2cc/clusterrole.yaml"} | ||
| c2ccClusterRoleBinding = []string{"components/c2cc/clusterrolebinding.yaml"} | ||
| c2ccDeployment = []string{"components/c2cc/deployment.yaml"} | ||
| c2ccService = []string{"components/c2cc/service.yaml"} | ||
| ) | ||
|
|
||
| func (c *C2CCRouteManager) deployProbe(ctx context.Context) error { | ||
| _, svcNet, err := net.ParseCIDR(c.cfg.Network.ServiceNetwork[0]) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to parse local service network: %w", err) | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| probeIP, err := cidr.Host(svcNet, 11) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to compute probe service ClusterIP: %w", err) | ||
| } | ||
|
|
||
| params := assets.RenderParams{ | ||
| "ReleaseImage": release.Image, | ||
| "ProbeServiceClusterIP": probeIP.String(), | ||
| } | ||
|
|
||
| if err := assets.ApplyNamespaces(ctx, c2ccNamespace, c.kubeconfig); err != nil { | ||
| return fmt.Errorf("failed to apply c2cc namespace: %w", err) | ||
| } | ||
| if err := assets.ApplyServiceAccounts(ctx, c2ccServiceAccount, c.kubeconfig); err != nil { | ||
| return fmt.Errorf("failed to apply c2cc service account: %w", err) | ||
| } | ||
| if err := assets.ApplyClusterRoles(ctx, c2ccClusterRole, c.kubeconfig); err != nil { | ||
| return fmt.Errorf("failed to apply c2cc cluster role: %w", err) | ||
| } | ||
| if err := assets.ApplyClusterRoleBindings(ctx, c2ccClusterRoleBinding, c.kubeconfig); err != nil { | ||
| return fmt.Errorf("failed to apply c2cc cluster role binding: %w", err) | ||
| } | ||
| if err := assets.ApplyDeployments(ctx, c2ccDeployment, renderTemplate, params, c.kubeconfig); err != nil { | ||
| return fmt.Errorf("failed to apply c2cc deployment: %w", err) | ||
| } | ||
| if err := assets.ApplyServices(ctx, c2ccService, renderTemplate, params, c.kubeconfig); err != nil { | ||
| return fmt.Errorf("failed to apply c2cc service: %w", err) | ||
| } | ||
|
|
||
| klog.V(4).Infof("C2CC probe assets deployed (probe ClusterIP=%s)", probeIP) | ||
| return nil | ||
| } | ||
|
|
||
| func renderTemplate(tb []byte, data assets.RenderParams) ([]byte, error) { | ||
| tmpl, err := template.New("").Option("missingkey=error").Parse(string(tb)) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| var buf bytes.Buffer | ||
| if err := tmpl.Execute(&buf, data); err != nil { | ||
| return nil, err | ||
| } | ||
| return buf.Bytes(), nil | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.