Skip to content

Commit 5047dc1

Browse files
authored
Merge pull request #41 from inspec/im/update_k8s_resource_docs
Reorganize Kubernetes resource docs
2 parents 421355e + 2364b56 commit 5047dc1

29 files changed

+175
-244
lines changed

docs-chef-io/config.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs-chef-io/content/_index.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
+++
2+
title = "About the Chef InSpec Kubernetes resource pack"
3+
draft = false
4+
linkTitle = "Kubernetes resource pack"
5+
summary = "Chef InSpec resources for auditing Kubernetes."
6+
7+
[cascade]
8+
[cascade.params]
9+
platform = "k8s"
10+
11+
[menu.k8s]
12+
title = "About Kubernetes resources"
13+
identifier = "inspec/resources/k8s/about"
14+
parent = "inspec/resources/k8s"
15+
weight = 10
16+
+++
17+
18+
Chef InSpec Kubernetes resources allow you to audit and validate the configuration, security, and compliance of your Kubernetes clusters.
19+
20+
## Requirements
21+
22+
- Inspec 3.7 or greater
23+
- InSpec K8s train/backend plugin [train-kubernetes](https://github.com/inspec/train-kubernetes)
24+
25+
## Usage
26+
27+
To create and run a profile against a Kubernetes cluster, follow these steps:
28+
29+
1. Ensure your `KUBECONFIG` environment variable or `~/.kube/config` file has a valid configuration and credentials for the target cluster.
30+
31+
1. Define the platform and this resource pack as a dependency in your profile's `inspec.yml` file:
32+
33+
```yml
34+
supports:
35+
platform: k8s
36+
depends:
37+
- name: inspec-k8s
38+
url: https://github.com/inspec/inspec-k8s/archive/main.tar.gz
39+
```
40+
41+
1. Define controls using the resources listed below.
42+
43+
1. Execute the profile against your cluster:
44+
45+
```sh
46+
inspec exec profile -t k8s://
47+
```
48+
49+
## Example
50+
51+
For an example profile, see the [inspec-k8s-sample example repository](https://github.com/inspec/inspec-k8s-sample).
52+
53+
## Kubernetes resources
54+
55+
{{< inspec_resources_filter >}}
56+
57+
The following Chef InSpec Kubernetes resources are available in this resource pack.
58+
59+
{{< inspec_resources section="k8s" platform="k8s" >}}

docs-chef-io/content/inspec/resources/k8s_api_resources.md renamed to docs-chef-io/content/k8s_api_resources.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
+++
22
title = "k8s_api_resources resource"
33
draft = false
4-
gh_repo = "inspec"
5-
platform = "k8s"
64

7-
[menu]
8-
[menu.inspec]
5+
[menu.k8s]
96
title = "k8s_api_resources"
107
identifier = "inspec/resources/k8s/K8s API Resources"
118
parent = "inspec/resources/k8s"
129
+++
1310

1411
Use the `k8s_api_resources` Chef InSpec audit resource to test the configurations of all resources under the specified API.
1512

16-
## Installation
17-
1813
## Syntax
1914

2015
```ruby
@@ -64,7 +59,7 @@ end
6459

6560
## Examples
6661

67-
### Resources under default API must exist
62+
Resources under default API must exist:
6863

6964
```ruby
7065
describe k8s_api_resources do
@@ -73,7 +68,7 @@ describe k8s_api_resources do
7368
end
7469
```
7570

76-
### Resources under specified API must exist and test its properties
71+
Resources under specified API must exist and test its properties:
7772

7873
```ruby
7974
describe k8s_api_resources(api: 'apps/v1') do
@@ -91,4 +86,4 @@ end
9186

9287
## Matchers
9388

94-
{{< readfile file="content/inspec/reusable/md/inspec_matchers_link.md" >}}
89+
{{< readfile file="content/reusable/md/inspec_matchers_link.md" >}}

docs-chef-io/content/inspec/resources/k8s_config_map.md renamed to docs-chef-io/content/k8s_config_map.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
+++
22
title = "k8s_config_map resource"
33
draft = false
4-
gh_repo = "inspec"
5-
platform = "k8s"
64

7-
[menu]
8-
[menu.inspec]
5+
[menu.k8s]
96
title = "k8s_config_map"
107
identifier = "inspec/resources/k8s/K8s Config Map"
118
parent = "inspec/resources/k8s"
129
+++
1310

1411
Use the `k8s_config_map` Chef InSpec audit resource to test the configuration of a specific Configuration Maps in a namespace.
1512

16-
## Installation
17-
1813
## Syntax
1914

2015
```ruby
@@ -50,15 +45,15 @@ end
5045

5146
## Examples
5247

53-
### Configuration map for default namespace must exist
48+
Configuration map for default namespace must exist:
5449

5550
```ruby
5651
describe k8s_config_map(name: 'NAME') do
5752
it { should exist }
5853
end
5954
```
6055

61-
### Configuration map for specified namespace must exist
56+
Configuration map for specified namespace must exist:
6257

6358
```ruby
6459
describe k8s_config_map(namespace: 'NAMESPACE', name: 'NAME') do
@@ -68,4 +63,4 @@ end
6863

6964
## Matchers
7065

71-
{{< readfile file="content/inspec/reusable/md/inspec_matchers_link.md" >}}
66+
{{< readfile file="content/reusable/md/inspec_matchers_link.md" >}}

docs-chef-io/content/inspec/resources/k8s_config_maps.md renamed to docs-chef-io/content/k8s_config_maps.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
+++
22
title = "k8s_config_maps resource"
33
draft = false
4-
gh_repo = "inspec"
5-
platform = "k8s"
64

7-
[menu]
8-
[menu.inspec]
5+
[menu.k8s]
96
title = "k8s_config_maps"
107
identifier = "inspec/resources/k8s/K8s Config Maps"
118
parent = "inspec/resources/k8s"
129
+++
1310

14-
1511
Use the `k8s_config_maps` Chef InSpec audit resource to test all the Configuration Maps in a namespace.
1612

17-
## Installation
18-
1913
## Syntax
2014

2115
```ruby
@@ -51,15 +45,15 @@ end
5145

5246
## Examples
5347

54-
### Configuration maps for default namespace must exist
48+
Configuration maps for default namespace must exist:
5549

5650
```ruby
5751
describe k8s_config_maps do
5852
it { should exist }
5953
end
6054
```
6155

62-
### Configuration maps must exists for specified namespace
56+
Configuration maps must exists for specified namespace:
6357

6458
```ruby
6559
describe k8s_config_maps(namespace: 'kube-system') do
@@ -69,4 +63,4 @@ end
6963

7064
## Matchers
7165

72-
{{< readfile file="content/inspec/reusable/md/inspec_matchers_link.md" >}}
66+
{{< readfile file="content/reusable/md/inspec_matchers_link.md" >}}

docs-chef-io/content/inspec/resources/k8s_container.md renamed to docs-chef-io/content/k8s_container.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
+++
22
title = "k8s_container resource"
33
draft = false
4-
gh_repo = "inspec"
5-
platform = "k8s"
64

7-
[menu]
8-
[menu.inspec]
5+
[menu.k8s]
96
title = "k8s_container"
107
identifier = "inspec/resources/k8s/K8s Container"
118
parent = "inspec/resources/k8s"
129
+++
1310

14-
1511
Use the `k8s_container` Chef InSpec audit resource to test the configuration of a specific Container in the specified namespace.
1612

17-
## Installation
18-
1913
## Syntax
2014

2115
```ruby
@@ -69,23 +63,23 @@ end
6963

7064
## Examples
7165

72-
### Container for default namespace must exist
66+
Container for default namespace must exist:
7367

7468
```ruby
7569
describe k8s_container(pod_name: 'POD_NAME', name: 'NAME') do
7670
it { should exist }
7771
end
7872
```
7973

80-
### Container for a specified namespace must exist
74+
Container for a specified namespace must exist:
8175

8276
```ruby
8377
describe k8s_container(namespace: 'NAMESPACE', name: 'NAME', pod_name: 'POD_NAME') do
8478
it { should exist }
8579
end
8680
```
8781

88-
### Check for presence of specific commands in Entrypoint array
82+
Check for presence of specific commands in Entrypoint array:
8983

9084
```ruby
9185
describe k8s_container(pod_name: 'POD_NAME', name: 'NAME') do
@@ -95,4 +89,4 @@ end
9589

9690
## Matchers
9791

98-
{{< readfile file="content/inspec/reusable/md/inspec_matchers_link.md" >}}
92+
{{< readfile file="content/reusable/md/inspec_matchers_link.md" >}}

docs-chef-io/content/inspec/resources/k8s_containers.md renamed to docs-chef-io/content/k8s_containers.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
+++
22
title = "k8s_containers resource"
33
draft = false
4-
gh_repo = "inspec"
5-
platform = "k8s"
64

7-
[menu]
8-
[menu.inspec]
5+
[menu.k8s]
96
title = "k8s_containers"
107
identifier = "inspec/resources/k8s/K8s Containers"
118
parent = "inspec/resources/k8s"
129
+++
1310

1411
Use the `k8s_containers` Chef InSpec audit resource to test the configurations of all Containers in a namespace.
1512

16-
## Installation
17-
1813
## Syntax
1914

2015
```ruby
@@ -62,23 +57,23 @@ end
6257

6358
## Examples
6459

65-
### Containers for default namespace must exist
60+
Containers for default namespace must exist:
6661

6762
```ruby
6863
describe k8s_containers do
6964
it { should exist }
7065
end
7166
```
7267

73-
### Containers for specified namespace must exist
68+
Containers for specified namespace must exist:
7469

7570
```ruby
7671
describe k8s_containers(namespace: 'kube-system') do
7772
it { should exist }
7873
end
7974
```
8075

81-
### Containers with readOnlyRootFilesystem exists
76+
Containers with readOnlyRootFilesystem exists:
8277

8378
```ruby
8479
describe k8s_containers(namespace: 'kube-system').where{ securityContext && securityContext[:readOnlyRootFilesystem] == true } do
@@ -89,4 +84,4 @@ end
8984

9085
## Matchers
9186

92-
{{< readfile file="content/inspec/reusable/md/inspec_matchers_link.md" >}}
87+
{{< readfile file="content/reusable/md/inspec_matchers_link.md" >}}

docs-chef-io/content/inspec/resources/k8s_cronjob.md renamed to docs-chef-io/content/k8s_cronjob.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
+++
22
title = "k8s_cronjob resource"
33
draft = false
4-
gh_repo = "inspec"
5-
platform = "k8s"
64

7-
[menu]
8-
[menu.inspec]
5+
[menu.k8s]
96
title = "k8s_cronjob"
107
identifier = "inspec/resources/k8s/K8s Cronjob"
118
parent = "inspec/resources/k8s"
129
+++
1310

14-
1511
Use the `k8s_cronjob` Chef InSpec audit resource to test the configuration of a specific CronJob in the specified namespace.
1612

17-
## Installation
18-
1913
## Syntax
2014

2115
```ruby
@@ -63,7 +57,7 @@ end
6357

6458
## Examples
6559

66-
### Cronjob for default namespace must exist and test its properties
60+
Cronjob for default namespace must exist and test its properties:
6761

6862
```ruby
6963
describe k8s_cronjob(name: 'HELLO') do
@@ -80,7 +74,7 @@ describe k8s_cronjob(name: 'HELLO') do
8074
end
8175
```
8276

83-
### Cronjob for a specified namespace must exist
77+
Cronjob for a specified namespace must exist:
8478

8579
```ruby
8680
describe k8s_cronjob(name: 'HELLO-WORLD', namespace: 'Namespace') do
@@ -90,4 +84,4 @@ end
9084

9185
## Matchers
9286

93-
{{< readfile file="content/inspec/reusable/md/inspec_matchers_link.md" >}}
87+
{{< readfile file="content/reusable/md/inspec_matchers_link.md" >}}

0 commit comments

Comments
 (0)