You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use the CLI to forward one or more local ports to a pod. This allows you
10
-
to listen on a given or random port locally, and have data forwarded to and from
11
-
given ports in the pod.
9
+
[role="_abstract"]
10
+
You can use the {oc-first} to forward one or more local ports to a pod. This allows you to listen on a given or random port locally, and have data forwarded to and from given ports in the pod.
12
11
13
-
Support for port forwarding is built into the CLI:
12
+
You can use a command similar to the following to forward one or more local ports to a pod.
Support for remote container command execution is built into the CLI.
9
+
[role="_abstract"]
10
+
You can use the {oc-first} to execute remote commands in {product-title} containers. By running commands in a container, you can perform troubleshooting, inspect logs, run scripts, and other tasks.
10
11
11
12
.Procedure
12
13
13
-
To run a command in a container:
14
-
14
+
* Use a command similar to the following to run a command in a container:
Copy file name to clipboardExpand all lines: modules/nodes-containers-start-pod-safe-sysctls.adoc
+22-16Lines changed: 22 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,8 @@
6
6
[id="nodes-starting-pod-safe-sysctls_{context}"]
7
7
= Starting a pod with safe sysctls
8
8
9
-
You can set sysctls on pods using the pod's `securityContext`. The `securityContext` applies to all containers in the same pod.
9
+
[role="_abstract"]
10
+
You can modify kernel parameters for all containers in a pod by adding the sysctls parameter to the `securityContext` parameter in a pod spec.
10
11
11
12
Safe sysctls are allowed by default.
12
13
@@ -22,7 +23,8 @@ This example uses the pod `securityContext` to set the following safe sysctls:
22
23
To avoid destabilizing your operating system, modify sysctl parameters only after you understand their effects.
23
24
====
24
25
25
-
Use this procedure to start a pod with the configured sysctl settings.
26
+
The following procedure shows how to start a pod with the configured sysctl settings.
27
+
26
28
[NOTE]
27
29
====
28
30
In most cases you modify an existing pod definition and add the `securityContext` spec.
@@ -46,14 +48,14 @@ spec:
46
48
image: centos
47
49
command: ["bin/bash", "-c", "sleep INF"]
48
50
securityContext:
49
-
runAsUser: 2000 <1>
50
-
runAsGroup: 3000 <2>
51
-
allowPrivilegeEscalation: false <3>
52
-
capabilities: <4>
51
+
runAsUser: 2000
52
+
runAsGroup: 3000
53
+
allowPrivilegeEscalation: false
54
+
capabilities:
53
55
drop: ["ALL"]
54
56
securityContext:
55
-
runAsNonRoot: true <5>
56
-
seccompProfile: <6>
57
+
runAsNonRoot: true
58
+
seccompProfile:
57
59
type: RuntimeDefault
58
60
sysctls:
59
61
- name: kernel.shm_rmid_forced
@@ -65,21 +67,25 @@ spec:
65
67
- name: net.ipv4.ping_group_range
66
68
value: "0 200000000"
67
69
----
68
-
<1> `runAsUser` controls which user ID the container is run with.
69
-
<2> `runAsGroup` controls which primary group ID the containers is run with.
70
-
<3> `allowPrivilegeEscalation` determines if a pod can request to allow privilege escalation. If unspecified, it defaults to true. This boolean directly controls whether the `no_new_privs` flag gets set on the container process.
71
-
<4> `capabilities` permit privileged actions without giving full root access. This policy ensures all capabilities are dropped from the pod.
72
-
<5> `runAsNonRoot: true` requires that the container will run with a user with any UID other than 0.
73
-
<6> `RuntimeDefault` enables the default seccomp profile for a pod or container workload.
70
+
where:
71
+
72
+
`spec.containers.securityContext.runAsUser`:: Specifies which user ID the container is run with.
73
+
`spec.containers.securityContext.runAsGroup`:: Specifies which primary group ID the containers is run with.
74
+
`spec.containers.securityContext.allowPrivilegeEscalation`:: Specifies whether a pod can request privilege escalation. The default is `true`. This boolean directly controls whether the `no_new_privs` flag gets set on the container process.
75
+
`spec.containers.securityContext.capabilities`:: Specifies permitted privileged actions without giving full root access. This policy ensures all capabilities are dropped from the pod.
76
+
`spec.securityContext.runAsNonRoot: true`:: Specifies that the container runs with a user with any UID other than 0.
77
+
`spec.securityContext.seccompProfile.type: RuntimeDefault`:: Specifies that the default seccomp profile is enabled for a pod or container workload.
74
78
75
79
. Create the pod by running the following command:
76
80
+
77
81
[source,terminal]
78
82
----
79
83
$ oc apply -f sysctl_pod.yaml
80
84
----
81
-
+
82
-
. Verify that the pod is created by running the following command:
85
+
86
+
.Verification
87
+
88
+
. Check that the pod is created by running the following command:
Copy file name to clipboardExpand all lines: modules/nodes-containers-sysctls-about.adoc
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,20 @@
6
6
[id="nodes-containers-sysctls-about_{context}"]
7
7
= About sysctls
8
8
9
-
In Linux, the sysctl interface allows an administrator to modify kernel parameters at runtime. Parameters are available from the `_/proc/sys/_` virtual process file system. The parameters cover various subsystems, such as:
9
+
[role="_abstract"]
10
+
The Linux sysctl interface allows you to modify kernel parameters at runtime to manage subsystems such as networking, virtual memory, and MDADM. By accessing the sysctl interface, you can view and adjust system configurations without rebooting the operating system.
11
+
12
+
You can modify the following subsystems by using sysctls:
10
13
11
14
- kernel (common prefix: `_kernel._`)
12
15
- networking (common prefix: `_net._`)
13
16
- virtual memory (common prefix: `_vm._`)
14
17
- MDADM (common prefix: `_dev._`)
15
18
16
-
More subsystems are described in link:https://www.kernel.org/doc/Documentation/sysctl/README[Kernel documentation].
17
-
To get a list of all parameters, run:
19
+
Refer to the link:https://www.kernel.org/doc/Documentation/sysctl/README[Kernel.org documentation] for more information on the subsystems you can manage.
20
+
You can get a list of all parameters by running the following command:
A pod with unsafe sysctls fails to launch on any node unless the cluster administrator explicitly enables unsafe sysctls for that node. As with node-level sysctls, use the taints and toleration feature or labels on nodes to schedule those pods onto the right nodes.
9
+
[role="_abstract"]
10
+
You can run a pod that is configured to use unsafe sysctls on a node where a cluster administrator explicitly enabled unsafe sysctls. You might use unsafe sysctls for situations such as high performance or real-time application tuning.
11
+
12
+
You can use the taints and toleration feature or labels on nodes to schedule those pods onto the right nodes.
10
13
11
14
The following example uses the pod `securityContext` to set a safe sysctl `kernel.shm_rmid_forced` and two unsafe sysctls, `net.core.somaxconn` and `kernel.msgmax`. There is no distinction between _safe_ and _unsafe_ sysctls in the specification.
0 commit comments