Skip to content

Commit

Permalink
docs: custom kubeconfigs on checks & topology lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Oct 2, 2024
1 parent 4f01d84 commit fdecd9e
Show file tree
Hide file tree
Showing 3 changed files with 339 additions and 8 deletions.
121 changes: 121 additions & 0 deletions canary-checker/docs/reference/1-kubernetes-resource.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,127 @@ check would be to see if a service is accessible via the ingress as shown in the
]}
/>

### Remote clusters

A single canary-checker instance can connect to any number of remote clusters via custom kubeconfig.

Check failure on line 121 in canary-checker/docs/reference/1-kubernetes-resource.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes-resource.mdx#L121

[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes-resource.mdx", "range": {"start": {"line": 121, "column": 90}}}, "severity": "ERROR"}
Either the kubeconfig itself or the path to the kubeconfig can be provided.

Check failure on line 122 in canary-checker/docs/reference/1-kubernetes-resource.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes-resource.mdx#L122

[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes-resource.mdx", "range": {"start": {"line": 122, "column": 12}}}, "severity": "ERROR"}

Check failure on line 122 in canary-checker/docs/reference/1-kubernetes-resource.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes-resource.mdx#L122

[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes-resource.mdx", "range": {"start": {"line": 122, "column": 49}}}, "severity": "ERROR"}

#### kubeconfig from kubernetes secret

Check failure on line 124 in canary-checker/docs/reference/1-kubernetes-resource.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes-resource.mdx#L124

[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes-resource.mdx", "range": {"start": {"line": 124, "column": 6}}}, "severity": "ERROR"}

```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
```
#### Kubeconfig inline

Check failure on line 158 in canary-checker/docs/reference/1-kubernetes-resource.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes-resource.mdx#L158

[Flanksource.Spelling] Is 'Kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'Kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes-resource.mdx", "range": {"start": {"line": 158, "column": 6}}}, "severity": "ERROR"}
```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
```
#### Kubeconfig from local filesystem

Check failure on line 209 in canary-checker/docs/reference/1-kubernetes-resource.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes-resource.mdx#L209

[Flanksource.Spelling] Is 'Kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'Kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes-resource.mdx", "range": {"start": {"line": 209, "column": 6}}}, "severity": "ERROR"}
```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
```
### Templating
The `resources` and `staticResources` fields can be templated using <CommonLink to="gotemplate">Go Templates</CommonLink>.
Expand Down
90 changes: 90 additions & 0 deletions canary-checker/docs/reference/1-kubernetes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,93 @@ dyn(results).all(x, k8s.isReady(x))
```
</div>
</details>


### Remote clusters

A single canary-checker instance can connect to any number of remote clusters via custom kubeconfig.

Check failure on line 77 in canary-checker/docs/reference/1-kubernetes.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes.mdx#L77

[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes.mdx", "range": {"start": {"line": 77, "column": 90}}}, "severity": "ERROR"}
Either the kubeconfig itself or the path to the kubeconfig can be provided.

Check failure on line 78 in canary-checker/docs/reference/1-kubernetes.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes.mdx#L78

[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes.mdx", "range": {"start": {"line": 78, "column": 12}}}, "severity": "ERROR"}

Check failure on line 78 in canary-checker/docs/reference/1-kubernetes.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes.mdx#L78

[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes.mdx", "range": {"start": {"line": 78, "column": 49}}}, "severity": "ERROR"}

#### kubeconfig from kubernetes secret

Check failure on line 80 in canary-checker/docs/reference/1-kubernetes.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes.mdx#L80

[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes.mdx", "range": {"start": {"line": 80, "column": 6}}}, "severity": "ERROR"}

```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
```
#### Kubeconfig inline

Check failure on line 104 in canary-checker/docs/reference/1-kubernetes.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes.mdx#L104

[Flanksource.Spelling] Is 'Kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'Kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes.mdx", "range": {"start": {"line": 104, "column": 6}}}, "severity": "ERROR"}
```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
```
#### Kubeconfig from local filesystem

Check failure on line 144 in canary-checker/docs/reference/1-kubernetes.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-kubernetes.mdx#L144

[Flanksource.Spelling] Is 'Kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'Kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-kubernetes.mdx", "range": {"start": {"line": 144, "column": 6}}}, "severity": "ERROR"}
```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
```
136 changes: 128 additions & 8 deletions mission-control/docs/topology/lookups/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Kubernetes

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

```yaml title="kube-check.yml"
```yaml title="kube-configmap-components.yml"
---
apiVersion: canaries.flanksource.com/v1
kind: Topology
Expand All @@ -15,7 +15,7 @@ metadata:
spec:
type: Config
icon: kubernetes
schedule: '@every 30s'
schedule: '@every 5m'
components:
- name: configs
icon: server
Expand All @@ -24,12 +24,13 @@ spec:
lookup:
kubernetes:
- kind: ConfigMap
display:
expr: |
dyn(results).map(c, {
'name': c.name,
'type': 'ConfigMap',
}).toJSON()
display:
expr: |
dyn(results).map(c, {
'name': c.Object.metadata.name,
'type': 'ConfigMap',
}).toJSON()
// highlight-end
```

Expand All @@ -55,3 +56,122 @@ spec:
## Results

The `results` variable in the template is itself a list of all the kubernetes resources.

## Remote clusters

A single canary-checker instance can connect to any number of remote clusters via custom kubeconfig.

Check failure on line 62 in mission-control/docs/topology/lookups/kubernetes.md

View workflow job for this annotation

GitHub Actions / vale

[vale] mission-control/docs/topology/lookups/kubernetes.md#L62

[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "mission-control/docs/topology/lookups/kubernetes.md", "range": {"start": {"line": 62, "column": 90}}}, "severity": "ERROR"}
Either the kubeconfig itself or the path to the kubeconfig can be provided.

Check failure on line 63 in mission-control/docs/topology/lookups/kubernetes.md

View workflow job for this annotation

GitHub Actions / vale

[vale] mission-control/docs/topology/lookups/kubernetes.md#L63

[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "mission-control/docs/topology/lookups/kubernetes.md", "range": {"start": {"line": 63, "column": 12}}}, "severity": "ERROR"}

Check failure on line 63 in mission-control/docs/topology/lookups/kubernetes.md

View workflow job for this annotation

GitHub Actions / vale

[vale] mission-control/docs/topology/lookups/kubernetes.md#L63

[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "mission-control/docs/topology/lookups/kubernetes.md", "range": {"start": {"line": 63, "column": 49}}}, "severity": "ERROR"}

### 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
```

### Kubeconfig inline

Check failure on line 99 in mission-control/docs/topology/lookups/kubernetes.md

View workflow job for this annotation

GitHub Actions / vale

[vale] mission-control/docs/topology/lookups/kubernetes.md#L99

[Flanksource.Spelling] Is 'Kubeconfig' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'Kubeconfig' spelled correctly? Is it missing code formatting?", "location": {"path": "mission-control/docs/topology/lookups/kubernetes.md", "range": {"start": {"line": 99, "column": 5}}}, "severity": "ERROR"}

```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
```

### 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
```

0 comments on commit fdecd9e

Please sign in to comment.