> For the complete documentation index, see [llms.txt](https://docs.cloudeka.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloudeka.ai/guidance-for-enterprise/deka-gpu/deka-gpu-security/deka-guard/create-guard-to-allow-egress-with-port.md).

# Create guard to Allow Egress with Port

Create guard to allow egress with a port is used to create a CloudekaGuard that will allow outbound traffic (egress) from pods with certain labels to pods with other labels, and only on certain ports. Using this script, you can control outbound access from pods that have the label app: client-default in the default namespace to pods that have the label app: web-app, and limit such access to only port 8080 using the TCP protocol. You can first run the following syntax to create a YAML file with the name allow-egress-with-port.

```bash
nano allow-egress-with-port.yaml
```

Copy and paste the following YAML contents.

```yaml
apiVersion: tenants.cloudeka.ai/v1alpha2
kind: CloudekaGuard
metadata:
  name: allow-egress-with-port
  namespace: default
spec:
  endpointSelector:
    matchLabels:
      app: client-default
  egress:
  - toEndpoints:
    - matchLabels:
        app: web-app
    toPorts:
    - ports:
      - port: "8080"
        protocol: TCP
```

After pasting the syntax, save the file by pressing Ctrl + O, then press the Enter key and exit the editor by pressing Ctrl + X. The next step is to apply Cloudeka Guard.

```bash
kubectl apply -f allow-egress-with-port.yaml
```
