forked from aws-samples/hardeneks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request aws-samples#18 from joshkurz/scalability
feat(scalability): adding first scalability checks
- Loading branch information
Showing
4 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import re | ||
from rich.panel import Panel | ||
import kubernetes | ||
|
||
from hardeneks import console | ||
from ...resources import Resources | ||
|
||
|
||
def check_EKS_version(resources: Resources): | ||
client = kubernetes.client.VersionApi() | ||
version = client.get_code() | ||
minor = version.minor | ||
|
||
if int(re.sub("[^0-9]", "", minor)) < 24: | ||
console.print( | ||
Panel( | ||
f"[red]EKS Version Should be greater or equal too 1.24. Current Version == {version.major}.{version.minor}", | ||
subtitle="[link=https://aws.github.io/aws-eks-best-practices/scalability/docs/control-plane/#use-eks-124-or-above]Click to see the guide[/link]", | ||
) | ||
) | ||
console.print() | ||
return False | ||
|
||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from hardeneks.resources import Resources | ||
from unittest.mock import patch | ||
|
||
from hardeneks.cluster_wide.scalability.control_plane import check_EKS_version | ||
|
||
|
||
class Version: | ||
def __init__(self, minor): | ||
self.major = 1 | ||
self.minor = minor | ||
|
||
|
||
@patch("kubernetes.client.VersionApi.get_code") | ||
def test_check_EKS_version(mocked_client): | ||
namespaced_resources = Resources( | ||
"some_region", "some_context", "some_cluster", [] | ||
) | ||
mocked_client.return_value = Version("23+") | ||
assert not check_EKS_version(namespaced_resources) | ||
mocked_client.return_value = Version("24+") | ||
assert check_EKS_version(namespaced_resources) | ||
mocked_client.return_value = Version("24") | ||
assert check_EKS_version(namespaced_resources) |