Skip to content

Commit

Permalink
chore: kubernetes resource checker from fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Oct 9, 2024
1 parent 9ea55f8 commit 3e30dfe
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 310 deletions.
2 changes: 1 addition & 1 deletion canary-checker/docs/reference/1-http.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ spec:
<details summary="Basic Authentication">

<div>
```yaml title="http_auth.yaml" file=../../../modules/canary-checker/fixtures/minimal/http_auth.yaml
```yaml title="http_auth.yaml" file=../../../modules/canary-checker/fixtures/minimal/http_auth_static_pass.yaml
```
</div>
</details>
Expand Down
107 changes: 3 additions & 104 deletions canary-checker/docs/reference/1-kubernetes-resource.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,118 +123,17 @@ Either the kubeconfig itself or the path to the kubeconfig can be provided.

#### kubeconfig from kubernetes secret

```yaml title="remote-cluster.yaml" {11-15}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetesResource:
- name: pod creation on aws cluster
namespace: default
description: "deploy httpbin"
kubeconfig:
valueFrom:
secretKeyRef:
name: aws-kubeconfig
key: kubeconfig
resources:
- apiVersion: v1
kind: Pod
metadata:
name: httpbin
namespace: default
labels:
app: httpbin
spec:
containers:
- name: httpbin
image: "kennethreitz/httpbin:latest"
ports:
- containerPort: 80
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-resource-check-kubeconfig-from-secrets.yaml {12-16}
```

#### Kubeconfig inline

```yaml title="remote-cluster.yaml" {11-32}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetesResource:
- name: pod creation on aws cluster
namespace: default
description: "deploy httpbin"
kubeconfig:
value: |
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: xxxxx
server: https://xxxxx.sk1.eu-west-1.eks.amazonaws.com
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
contexts:
- context:
cluster: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
namespace: mission-control
user: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
current-context: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
kind: Config
preferences: {}
users:
- name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
user:
exec:
....
resources:
- apiVersion: v1
kind: Pod
metadata:
name: httpbin
namespace: default
labels:
app: httpbin
spec:
containers:
- name: httpbin
image: "kennethreitz/httpbin:latest"
ports:
- containerPort: 80
```yaml title="remote-cluster.yaml" yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-resource-check-inline-kubeconfig.yaml {12-33}
```

#### Kubeconfig from local filesystem

```yaml title="remote-cluster.yaml" {11-12}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetesResource:
- name: pod creation on aws cluster
namespace: default
description: "deploy httpbin"
kubeconfig:
value: /root/.kube/aws-kubeconfig
resources:
- apiVersion: v1
kind: Pod
metadata:
name: httpbin
namespace: default
labels:
app: httpbin
spec:
containers:
- name: httpbin
image: "kennethreitz/httpbin:latest"
ports:
- containerPort: 80
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-resource-check-kubeconfig-from-file.yaml {12-13}
```

### Templating
Expand Down
77 changes: 4 additions & 73 deletions canary-checker/docs/reference/1-kubernetes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,87 +76,18 @@ dyn(results).all(x, k8s.isReady(x))

A single canary-checker instance can connect to any number of remote clusters via custom kubeconfig.
Either the kubeconfig itself or the path to the kubeconfig can be provided.

#### kubeconfig from kubernetes secret

```yaml title="remote-cluster.yaml" {11-15}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetes:
- name: pod creation on aws cluster
namespace: default
description: "deploy httpbin"
kubeconfig:
valueFrom:
secretKeyRef:
name: aws-kubeconfig
key: kubeconfig
kind: Pod
ready: true
namespaceSelector:
name: default
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-check-kubeconfig-from-secrets.yaml {12-16}
```

#### Kubeconfig inline

```yaml title="remote-cluster.yaml" {10-31}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetes:
- name: pod creation on aws cluster
namespace: default
kubeconfig:
value: |
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: xxxxx
server: https://xxxxx.sk1.eu-west-1.eks.amazonaws.com
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
contexts:
- context:
cluster: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
namespace: mission-control
user: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
current-context: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
kind: Config
preferences: {}
users:
- name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
user:
exec:
....
kind: Pod
ready: true
namespaceSelector:
name: default
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-check-inline-kubeconfig.yaml {11-32}
```

#### Kubeconfig from local filesystem

```yaml title="remote-cluster.yaml" {10-11}
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: pod-creation-test
spec:
schedule: "@every 5m"
kubernetes:
- name: pod creation on aws cluster
namespace: default
kubeconfig:
value: /root/.kube/aws-kubeconfig
kind: Pod
ready: true
namespaceSelector:
name: default
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/k8s/kubernetes-check-kubeconfig-from-file.yaml {11-12}
```
136 changes: 8 additions & 128 deletions mission-control/docs/topology/lookups/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,8 @@ title: Kubernetes

The Kubernetes component lookup fetches kubernetes resources to be used as components.

```yaml title="kube-configmap-components.yml"
---
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
name: kubernetes-configs
spec:
type: Config
icon: kubernetes
schedule: '@every 5m'
components:
- name: configs
icon: server
type: ConfigMap
// highlight-start
lookup:
kubernetes:
- kind: ConfigMap
display:
expr: |
dyn(results).map(c, {
'name': c.Object.metadata.name,
'type': 'ConfigMap',
}).toJSON()
// highlight-end
```yaml title="kube-configmap-components.yaml" file=../../../modules/canary-checker/fixtures/topology/kubernetes-lookup.yaml {14-22}

```

| Field | Description | Scheme | Required |
Expand Down Expand Up @@ -64,114 +40,18 @@ Either the kubeconfig itself or the path to the kubeconfig can be provided.

### From kubernetes secret

```yaml title="remote-cluster.yaml"
---
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
name: kubernetes-configs
spec:
type: Config
icon: kubernetes
schedule: '@every 5m'
components:
- name: configs
icon: server
type: ConfigMap
lookup:
kubernetes:
- kind: ConfigMap
display:
expr: |
dyn(results).map(c, {
'name': c.Object.metadata.name,
'type': 'ConfigMap',
}).toJSON()
// highlight-start
kubeconfig:
valueFrom:
secretKeyRef:
name: aws-kubeconfig
key: kubeconfig
// highlight-end
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/topology/kubernetes-lookup-kubeconfig-from-secrets.yaml {23-27}

```

### Kubeconfig inline

```yaml title="remote-cluster.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
name: kubernetes-configs
spec:
type: Config
icon: kubernetes
schedule: '@every 5m'
components:
- name: configs
icon: server
type: ConfigMap
lookup:
kubernetes:
- kind: ConfigMap
display:
expr: |
dyn(results).map(c, {
'name': c.Object.metadata.name,
'type': 'ConfigMap',
}).toJSON()
// highlight-start
kubeconfig:
value: |
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: xxxxx
server: https://xxxxx.sk1.eu-west-1.eks.amazonaws.com
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
contexts:
- context:
cluster: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
namespace: mission-control
user: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
current-context: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
kind: Config
preferences: {}
users:
- name: arn:aws:eks:eu-west-1:765618022540:cluster/aws-cluster
user:
exec:
....
// highlight-end
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/topology/kubernetes-lookup-inline-configmap.yaml {22-48}

```

### From local filesystem

```yaml title="remote-cluster.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
name: kubernetes-configs
spec:
type: Config
icon: kubernetes
schedule: '@every 5m'
components:
- name: configs
icon: server
type: ConfigMap
lookup:
kubernetes:
- kind: ConfigMap
display:
expr: |
dyn(results).map(c, {
'name': c.name,
'type': 'ConfigMap',
}).toJSON()
// highlight-start
kubeconfig:
value: /root/.kube/aws-kubeconfig
// highlight-end
```yaml title="remote-cluster.yaml" file=../../../modules/canary-checker/fixtures/topology/kubernetes-lookup-kubeconfig-from-file.yaml {22-23}

```
2 changes: 1 addition & 1 deletion modules/canary-checker
Submodule canary-checker updated 63 files
+0 −1 chart/values.yaml
+64 −15 cmd/root.go
+2 −1 fixtures/aws/s3_bucket_pass.yaml
+1 −1 fixtures/datasources/GCP/database_backup.yaml
+18 −0 fixtures/datasources/GCP/database_backup_cred.yaml
+14 −0 fixtures/datasources/GCP/database_backup_cred_from_connection.yaml
+25 −0 fixtures/datasources/alertmanager.yaml
+11 −0 fixtures/datasources/folder_single_pass.yaml
+13 −0 fixtures/datasources/folder_with_filter.yaml
+26 −0 fixtures/datasources/postgres.yaml
+73 −0 fixtures/elasticsearch/stateful_metrics.yaml
+1 −1 fixtures/external/catalog.yaml
+1 −1 fixtures/external/crossplane-kubernetes-resource.yaml
+21 −0 fixtures/k8s/helm_check.yaml
+2 −1 fixtures/k8s/http_auth_configmap.yaml
+2 −1 fixtures/k8s/http_auth_secret.yaml
+35 −0 fixtures/k8s/kubernetes-check-inline-kubeconfig.yaml
+16 −0 fixtures/k8s/kubernetes-check-kubeconfig-from-file.yaml
+20 −0 fixtures/k8s/kubernetes-check-kubeconfig-from-secrets.yaml
+47 −0 fixtures/k8s/kubernetes-resource-check-inline-kubeconfig.yaml
+27 −0 fixtures/k8s/kubernetes-resource-check-kubeconfig-from-file.yaml
+30 −0 fixtures/k8s/kubernetes-resource-check-kubeconfig-from-secrets.yaml
+11 −0 fixtures/minimal/containerd-pull.yaml
+11 −0 fixtures/minimal/containerd-push.yaml
+11 −0 fixtures/minimal/display-with-cel_pass.yaml
+11 −0 fixtures/minimal/display-with-gotemplate_pass.yaml
+19 −0 fixtures/minimal/display-with-javascript_pass.yaml
+23 −0 fixtures/minimal/http_auth_from_config_map.yaml
+15 −0 fixtures/minimal/http_auth_from_helm_ref.yaml
+23 −0 fixtures/minimal/http_auth_from_secret.yaml
+20 −0 fixtures/minimal/http_auth_from_service_account.yaml
+3 −3 fixtures/minimal/http_auth_static_pass.yaml
+2 −2 fixtures/minimal/http_fail.yaml
+2 −3 fixtures/minimal/http_pass.yaml
+11 −0 fixtures/minimal/http_simple.yaml
+14 −0 fixtures/minimal/http_single_pass.yaml
+1 −1 fixtures/minimal/http_template.yaml
+1 −1 fixtures/minimal/http_timeout_fail.yaml
+11 −0 fixtures/minimal/http_tls_check_pass.yaml
+15 −0 fixtures/minimal/http_tls_config.yaml
+11 −0 fixtures/minimal/http_trace_pass.yaml
+1 −1 fixtures/minimal/icmp_fail.yaml
+15 −0 fixtures/minimal/jmeter.yaml
+6 −2 fixtures/minimal/kustomization.yaml
+1 −1 fixtures/minimal/tcp.yaml
+2 −1 fixtures/quarantine/icmp_pass.yaml
+8 −6 fixtures/quarantine/s3_fail.yaml
+3 −3 fixtures/topology/component-with-for-each.yml
+5 −5 fixtures/topology/component-with-properties.yml
+43 −0 fixtures/topology/kubernetes-lookup-inline-configmap.yaml
+23 −0 fixtures/topology/kubernetes-lookup-kubeconfig-from-file.yaml
+27 −0 fixtures/topology/kubernetes-lookup-kubeconfig-from-secrets.yaml
+22 −0 fixtures/topology/kubernetes-lookup.yaml
+3 −3 go.mod
+6 −6 go.sum
+27 −11 pkg/controllers/canary_controller.go
+8 −4 pkg/db/canary.go
+2 −1 pkg/jobs/canary/canary_jobs.go
+3 −2 pkg/jobs/canary/sync.go
+4 −0 pkg/runner/runner.go
+5 −5 pkg/system_api.go
+34 −0 pkg/utils/utils.go
+64 −0 pkg/utils/utils_test.go
2 changes: 1 addition & 1 deletion modules/mission-control

0 comments on commit 3e30dfe

Please sign in to comment.