Skip to content

Commit 46fe901

Browse files
author
sangam14
committed
update
1 parent 3b2315f commit 46fe901

File tree

5 files changed

+87
-22
lines changed

5 files changed

+87
-22
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: "NetworkPolicy "
3+
description: "networking"
4+
weight: 15
5+
---
6+
7+
It looks like you want to apply a Kubernetes NetworkPolicy that you've defined in a file using `kubectl`, the command-line tool for interacting with Kubernetes. If you're asking about how to handle file input operations including the end-of-file (EOF) marker for creating or editing files directly in the command line, I can guide you through creating or appending to a file using terminal commands.
8+
9+
### Creating a File with EOF Marker
10+
To create a new file or overwrite an existing file with your NetworkPolicy content directly from the terminal, you can use the following method:
11+
12+
```bash
13+
cat <<EOF > networkpolicy.yaml
14+
kind: NetworkPolicy
15+
apiVersion: networking.k8s.io/v1
16+
metadata:
17+
name: access-nginx # pick a name
18+
spec:
19+
podSelector:
20+
matchLabels:
21+
app: nginx # selector for the pods
22+
ingress: # allow ingress traffic
23+
- from:
24+
- podSelector: # from pods
25+
matchLabels: # with this label
26+
access: granted
27+
EOF
28+
```
29+
30+
This command will start `cat` in "here document" mode, which allows input until the end-of-file marker `EOF` is reached. The content between the initial `cat <<EOF > networkpolicy.yaml` and the final `EOF` is written into the `networkpolicy.yaml` file.
31+
32+
### Applying the NetworkPolicy
33+
Once you have the file ready (`networkpolicy.yaml`), you can apply it to your Kubernetes cluster with this command:
34+
35+
```bash
36+
kubectl apply -f networkpolicy.yaml
37+
```
38+
39+
This command tells `kubectl` to apply the configurations defined in `networkpolicy.yaml` to your Kubernetes cluster.
40+
41+
### Checking the Application of the NetworkPolicy
42+
After applying the NetworkPolicy, you can confirm it's been applied correctly by listing all network policies in the `default` namespace:
43+
44+
```bash
45+
kubectl get networkpolicy -n default
46+
```
47+
48+
This will display all network policies that have been configured in the `default` namespace, including your new `internal-policy`.
49+
50+
These steps will help you create, apply, and verify the application of your Kubernetes NetworkPolicy directly from the command line. If you have any more questions or need further assistance with Kubernetes, feel free to ask!
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: "Use Core DNS"
3+
description: "networking"
4+
weight: 16
5+
---
6+
7+
8+
sangam@sangam:~$ kubectl create service clusterip my-service --tcp=8080:8080
9+
service/my-service created
10+
sangam@sangam:~$ kubectl get service
11+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
12+
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 45h
13+
my-service ClusterIP 10.106.213.25 <none> 8080/TCP 5s
14+
sangam@sangam:~$ kubectl run busybox --image=busybox -it -- /bin/sh
15+
If you don't see a command prompt, try pressing enter.
16+
/ #
17+
/ #
18+
/ # nslookup 10.106.213.25
19+
Server: 10.96.0.10
20+
Address: 10.96.0.10:53
21+
22+
25.213.106.10.in-addr.arpa name = my-service.default.svc.cluster.local
23+
24+
/ # exit
25+
26+

readme.md

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,6 @@ git clone https://github.com/kubernetesdaily/dockerworkshop.git
116116
git clone https://github.com/kubernetesdaily/k8sworkshop.git
117117
```
118118

119-
10 Labs
120-
121-
| No. | Title |
122-
|--- | --------- |
123-
|1 | Pre-requisit for this lab| [🔗](
124-
125-
|8 | Service Type: NodePort,ClusterIP,LoadBalancer|
126-
|9 | Ingress Controller| [🔗](
127-
128-
129119
#### Cluster Architecture, Installation, and Configuration
130120

131121
| No. | Title | Link |
@@ -147,23 +137,22 @@ git clone https://github.com/kubernetesdaily/k8sworkshop.git
147137
|3 | Multi-Container Pods | [🔗](/content/docs/kubernetes/multipod-container.md)|
148138
|4 | Labels & Selectors| [🔗](./content/docs/kubernetes/labels-selectors.md)|
149139
|5 | Kubernetes Service| [🔗](./content/docs/kubernetes/Services.md)|
150-
|6 |Understand deployments and how to perform rolling update and rollbacks||[🔗](content/docs/kubernetes/Deployment-Replicaset.md)|
151-
|7 |Use ConfigMaps and Secrets to configure applications||[🔗](content/docs/kubernetes/ConfigMap.md) |
152-
|8 |Know how to scale applications||[🔗]( |
153-
|9 |Understand the primitives used to create robust, self-healing, application deployments||[🔗]( |
154-
|10 |Understand how resource limits can affect Pod scheduling||[🔗]( |
155-
|11 |Awareness of manifest management and common templating tools||[🔗]( |
140+
|6 |Understand deployments and how to perform rolling update and rollbacks|[🔗](content/docs/kubernetes/Deployment-Replicaset.md)|
141+
|7 |Use ConfigMaps and Secrets to configure applications|[🔗](content/docs/kubernetes/ConfigMap.md)|
142+
|8|Understand the primitives used to create robust, self-healing, application deployments||[🔗]( |
143+
|9 |Understand how resource limits can affect Pod scheduling||[🔗]( |
144+
|10 |Awareness of manifest management and common templating tools||[🔗]( |
156145

157146
#### Services and Networking
158147

159148
| No. | Title |
160149
|--- | --------- |
161-
|1 |Understand host networking configuration on the cluster nodes||[🔗](
162-
|2 |Understand connectivity between Pods||[🔗](
163-
|3 |Understand ClusterIP, NodePort, LoadBalancer service types and endpoints||[🔗](
164-
|4 |Know how to use Ingress controllers and Ingress resources ||[🔗](
165-
|5 |Know how to configure and use CoreDNS ||[🔗](
166-
|6 |Choose an appropriate container network interface plugin ||[🔗](
150+
|1 |Understand host networking configuration on the cluster nodes|[🔗]( |
151+
|2 |Understand connectivity between Pods|[🔗]( |
152+
|3 |Understand ClusterIP, NodePort, LoadBalancer service types and endpoints|[🔗](./content/docs/kubernetes/Service-Type.md)|
153+
|4 |Know how to use Ingress controllers and Ingress resources |[🔗](./content/docs/kubernetes/Ingress-Controller.md)|
154+
|5 |Know how to configure and use CoreDNS |[🔗]( |
155+
|6 |Choose an appropriate container network interface plugin |[🔗]( |
167156

168157
#### Storage
169158

46.9 KB
Loading
46.7 KB
Loading

0 commit comments

Comments
 (0)