Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sangam14 committed Apr 28, 2024
1 parent 3b2315f commit 46fe901
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 22 deletions.
50 changes: 50 additions & 0 deletions content/docs/kubernetes/networkpolicy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "NetworkPolicy "
description: "networking"
weight: 15
---

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.

### Creating a File with EOF Marker
To create a new file or overwrite an existing file with your NetworkPolicy content directly from the terminal, you can use the following method:

```bash
cat <<EOF > networkpolicy.yaml
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: access-nginx # pick a name
spec:
podSelector:
matchLabels:
app: nginx # selector for the pods
ingress: # allow ingress traffic
- from:
- podSelector: # from pods
matchLabels: # with this label
access: granted
EOF
```

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.

### Applying the NetworkPolicy
Once you have the file ready (`networkpolicy.yaml`), you can apply it to your Kubernetes cluster with this command:

```bash
kubectl apply -f networkpolicy.yaml
```

This command tells `kubectl` to apply the configurations defined in `networkpolicy.yaml` to your Kubernetes cluster.

### Checking the Application of the NetworkPolicy
After applying the NetworkPolicy, you can confirm it's been applied correctly by listing all network policies in the `default` namespace:

```bash
kubectl get networkpolicy -n default
```

This will display all network policies that have been configured in the `default` namespace, including your new `internal-policy`.

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!
26 changes: 26 additions & 0 deletions content/docs/kubernetes/use-core-dns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: "Use Core DNS"
description: "networking"
weight: 16
---


sangam@sangam:~$ kubectl create service clusterip my-service --tcp=8080:8080
service/my-service created
sangam@sangam:~$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 45h
my-service ClusterIP 10.106.213.25 <none> 8080/TCP 5s
sangam@sangam:~$ kubectl run busybox --image=busybox -it -- /bin/sh
If you don't see a command prompt, try pressing enter.
/ #
/ #
/ # nslookup 10.106.213.25
Server: 10.96.0.10
Address: 10.96.0.10:53

25.213.106.10.in-addr.arpa name = my-service.default.svc.cluster.local

/ # exit


33 changes: 11 additions & 22 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,6 @@ git clone https://github.com/kubernetesdaily/dockerworkshop.git
git clone https://github.com/kubernetesdaily/k8sworkshop.git
```

10 Labs

| No. | Title |
|--- | --------- |
|1 | Pre-requisit for this lab| [🔗](

|8 | Service Type: NodePort,ClusterIP,LoadBalancer|
|9 | Ingress Controller| [🔗](


#### Cluster Architecture, Installation, and Configuration

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

#### Services and Networking

| No. | Title |
|--- | --------- |
|1 |Understand host networking configuration on the cluster nodes||[🔗](
|2 |Understand connectivity between Pods||[🔗](
|3 |Understand ClusterIP, NodePort, LoadBalancer service types and endpoints||[🔗](
|4 |Know how to use Ingress controllers and Ingress resources ||[🔗](
|5 |Know how to configure and use CoreDNS ||[🔗](
|6 |Choose an appropriate container network interface plugin ||[🔗](
|1 |Understand host networking configuration on the cluster nodes|[🔗]( |
|2 |Understand connectivity between Pods|[🔗]( |
|3 |Understand ClusterIP, NodePort, LoadBalancer service types and endpoints|[🔗](./content/docs/kubernetes/Service-Type.md)|
|4 |Know how to use Ingress controllers and Ingress resources |[🔗](./content/docs/kubernetes/Ingress-Controller.md)|
|5 |Know how to configure and use CoreDNS |[🔗]( |
|6 |Choose an appropriate container network interface plugin |[🔗]( |

#### Storage

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 46fe901

Please sign in to comment.