Skip to content
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

tool: validator script for Azure NPM to Cilium migration #3372

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
087b1c1
npm to cilium validator script
rayaisaiah Jan 28, 2025
eb5f727
added a check for services with target ports
rayaisaiah Feb 3, 2025
69a71be
Merge branch 'master' into isaiahraya/npm-cilium-migration-script
rayaisaiah Feb 3, 2025
843741b
update for lint errors with repeat imports and using slice of pointer…
rayaisaiah Feb 3, 2025
49fa49a
made a function to reuse for Ingress and egress ports
rayaisaiah Feb 4, 2025
079e7c0
added some unit tests except for service check and made print stateme…
rayaisaiah Feb 4, 2025
07690ae
updated engress policy check with egress allow all policy and added a…
rayaisaiah Feb 4, 2025
5b5d2a7
changed file path
rayaisaiah Feb 4, 2025
d6ec15e
added namedport checks and added port to ingress check
rayaisaiah Feb 4, 2025
dd25cc8
responded to service comments
rayaisaiah Feb 5, 2025
afa4e9d
added a check for ingress deny all and updated port check function to…
rayaisaiah Feb 5, 2025
7625ef5
updated to return lists and use pointers but still broken for services
rayaisaiah Feb 5, 2025
b9231e2
added pointers to service check functions
rayaisaiah Feb 5, 2025
2f7d338
fixed pointer logic and added unit tests for the checks except service
rayaisaiah Feb 6, 2025
cd15f4a
Merge branch 'master' into isaiahraya/npm-cilium-migration-script
rayaisaiah Feb 6, 2025
c8bd575
fixed all linter errors
rayaisaiah Feb 6, 2025
f2cba91
updated difference function with comment to use a set
rayaisaiah Feb 6, 2025
1b64afb
fixed linter problems induced by previous commit
rayaisaiah Feb 6, 2025
a2d413f
added complete UTs for GetEndportNetworkPolicies, GetCIDRNetworkPolic…
rayaisaiah Feb 6, 2025
c329191
added baseline service tests and updated logic for unsafe and noselec…
rayaisaiah Feb 6, 2025
f79188b
added more service uts for nodeport and organized scenarios
rayaisaiah Feb 7, 2025
593f29e
updated migration check to be less than 200 characters per line (lint…
rayaisaiah Feb 7, 2025
840feab
updated getExternalTrafficPolicyClusterServices to be less than 200 c…
rayaisaiah Feb 7, 2025
894da23
removed unused parameter and added edge case scenarios to UTs
rayaisaiah Feb 7, 2025
bbe17e6
simplified logic
rayaisaiah Feb 7, 2025
3ee1deb
updated port detection when policy just has a protocol and to flag al…
rayaisaiah Feb 7, 2025
c4676cf
resolved nit: pointer to slice is also a pointer to pointer comment
rayaisaiah Feb 7, 2025
c72b33c
responded to comments return false when either port or target port is…
rayaisaiah Feb 7, 2025
51e0d16
added readme, go mod, go sum, and comments saying why target port wil…
rayaisaiah Feb 7, 2025
ede206d
updated readme
rayaisaiah Feb 7, 2025
5805952
updated functions using pointers for arrays
rayaisaiah Feb 7, 2025
1689071
nit changes
rayaisaiah Feb 7, 2025
f35989c
updated with match expressions edgecase
rayaisaiah Feb 7, 2025
160fd47
added uts where target port matches to protocol and port is 0
rayaisaiah Feb 7, 2025
979a8b3
added Scenarios where there are LoadBalancer or NodePort services wit…
rayaisaiah Feb 8, 2025
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
51 changes: 51 additions & 0 deletions tools/azure-npm-to-cilium-validator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Azure NPM to Cilium Validator

This tool validates the migration from Azure NPM to Cilium. It will provide information on if you can safely proceed with a manual update from Azure NPM to Cilium. It will verify the following checks to determine if the cluster is safe to migrate.

- NetworkPolicy with endPort
- NetworkPolicy with ipBlock
- NetworkPolicy with Egress Policies (not Allow All)
- Disruption for some Services (LoadBalancer or NodePort) with externalTrafficPolicy=Cluster

## Prerequisites

- Go 1.16 or later
- A Kubernetes cluster with Azure NPM installed

## Installation

Clone the repository and navigate to the tool directory:

```bash
git clone https://github.com/Azure/azure-container-networking.git
cd azure-container-networking/tools/azure-npm-to-cilium-validator
```

## Setting Up Dependencies

Initialize the Go module and download dependencies:

```bash
go mod tidy
go mod vendor
```

## Running the Tool

Run the following command with the path to your kube config file with the cluster you want to validate.

```bash
go run azure-npm-to-cilium-validator.go --kubeconfig ~/.kube/config
```

This will execute the validator and print the migration summary.

## Running Tests

To run the tests for the Azure NPM to Cilium Validator, use the following command in the azure-npm-to-cilium-validator directory:

```bash
go test .
```

This will execute all the test files in azure-npm-to-cilium-validator_test.go and provide a summary of the test results.
Loading
Loading