Skip to content

resolve: replicas issue and add network testing section #1388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions examples/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,72 @@ Let’s look at an example of creating a multi-instance WordPress Service using
helm delete kubeplus -n $KUBEPLUS_NS
python3 provider-kubeconfig.py delete $KUBEPLUS_NS
```

## Network Isolation Testing

This section verifies that the network policies are correctly isolating application instances.

### Steps

#### Install a Network Driver

On Minikube, install a network driver capable of recognizing `NetworkPolicy` objects (e.g., Cilium):

```bash
$ minikube start --cni=cilium
$ eval $(minikube docker-env)
```

#### Refer main README for installing the kubeplus operator and plugings

#### Create HelloWorldService Instances

```bash
$ kubectl create -f hello-world-service-composition.yaml --kubeconfig=provider.conf
$ kubectl create -f hs1.yaml --kubeconfig=provider.conf
$ kubectl create -f hs2.yaml --kubeconfig=provider.conf
```

#### Test Network Isolation

- **Ping/HTTP Test from `hs1` to `hs2`:**

```bash
# Get the Pod name for hs1
HELLOWORLD_POD_HS1=$(kubectl get pods -n hs1 --kubeconfig=provider.conf -o jsonpath='{.items[0].metadata.name}')

# Get the Pod IP for hs2
HS2_POD_IP=$(kubectl get pods -n hs2 --kubeconfig=provider.conf -o jsonpath='{.items[0].status.podIP}')

# Test connectivity from hs1 to hs2 using the IP
kubectl exec -it $HELLOWORLD_POD_HS1 -n hs1 --kubeconfig=provider.conf -- curl $HS2_POD_IP
```

The connection should be denied.

- **Ping/HTTP Test from `hs2` to `hs1`:**

```bash
# Get the Pod name for hs2
HELLOWORLD_POD_HS2=$(kubectl get pods -n hs2 --kubeconfig=provider.conf -o jsonpath='{.items[0].metadata.name}')

# Get the Pod IP for hs1
HS1_POD_IP=$(kubectl get pods -n hs1 --kubeconfig=provider.conf -o jsonpath='{.items[0].status.podIP}')

# Test connectivity from hs2 to hs1 using the IP
kubectl exec -it $HELLOWORLD_POD_HS2 -n hs2 --kubeconfig=provider.conf -- curl $HS1_POD_IP
```

The connection should be denied.

## Clean Up


```bash
$ kubectl delete -f hs1-no-replicas.yaml --kubeconfig=provider.conf
$ kubectl delete -f hs2-no-replicas.yaml --kubeconfig=provider.conf
$ kubectl delete -f hello-world-service-composition.yaml --kubeconfig=provider.conf
```


Ensure the `helloworldservices.platformapi.kubeplus` CRD is removed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
version: v1alpha1
plural: helloworldservices
# URL of the Helm chart that contains Kubernetes resources that represent a workflow.
chartURL: https://github.com/cloud-ark/operatorcharts/blob/master/hello-world-chart-0.0.2.tgz?raw=true
chartURL: https://github.com/cloud-ark/kubeplus/blob/master/examples/multitenancy/hello-world/hello-world-chart-0.0.3.tgz?raw=true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

chartName: hello-world-chart
# respolicy defines the resource policy to be applied to instances of the specified custom resource.
respolicy:
Expand Down