k8s-helper-cli 0.2.1__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/PKG-INFO +1 -1
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/pyproject.toml +1 -1
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper/__init__.py +1 -1
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper/cli.py +40 -3
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper/core.py +103 -11
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper_cli.egg-info/PKG-INFO +1 -1
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/LICENSE +0 -0
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/README.md +0 -0
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/setup.cfg +0 -0
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper/config.py +0 -0
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper/utils.py +0 -0
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper_cli.egg-info/SOURCES.txt +0 -0
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper_cli.egg-info/dependency_links.txt +0 -0
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper_cli.egg-info/entry_points.txt +0 -0
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper_cli.egg-info/requires.txt +0 -0
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper_cli.egg-info/top_level.txt +0 -0
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/tests/test_core.py +0 -0
- {k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/tests/test_integration.py +0 -0
@@ -691,7 +691,16 @@ def create_eks_cluster(
|
|
691
691
|
console.print(f"💻 Instance types: {instance_type_list}")
|
692
692
|
console.print(f"📊 Scaling: {min_size}-{max_size} nodes (desired: {desired_size})")
|
693
693
|
|
694
|
-
|
694
|
+
# Show what will be created
|
695
|
+
console.print("\n🔧 EKS Requirements:")
|
696
|
+
console.print(" • IAM roles for cluster and node groups")
|
697
|
+
console.print(" • VPC subnets in at least 2 availability zones")
|
698
|
+
console.print(" • Security groups for cluster communication")
|
699
|
+
console.print(" • EKS cluster control plane")
|
700
|
+
if node_group:
|
701
|
+
console.print(" • Managed node group with EC2 instances")
|
702
|
+
|
703
|
+
with console.status("Creating EKS cluster and required resources..."):
|
695
704
|
cluster_info = eks_client.create_cluster(
|
696
705
|
cluster_name=name,
|
697
706
|
version=version,
|
@@ -704,6 +713,9 @@ def create_eks_cluster(
|
|
704
713
|
console.print(f"📋 Cluster ARN: {cluster_info['cluster_arn']}")
|
705
714
|
console.print(f"🕐 Created at: {cluster_info['created_at']}")
|
706
715
|
|
716
|
+
if 'subnets' in cluster_info:
|
717
|
+
console.print(f"🌐 Subnets: {cluster_info['subnets']}")
|
718
|
+
|
707
719
|
if wait:
|
708
720
|
console.print("⏳ Waiting for cluster to become active...")
|
709
721
|
with console.status("Waiting for cluster to be ready..."):
|
@@ -713,13 +725,38 @@ def create_eks_cluster(
|
|
713
725
|
# Show cluster status
|
714
726
|
status = eks_client.get_cluster_status(name)
|
715
727
|
console.print(f"🔗 Endpoint: {status['endpoint']}")
|
728
|
+
|
729
|
+
# Show next steps
|
730
|
+
console.print(f"\n🚀 Next steps:")
|
731
|
+
console.print(f" 1. Configure kubectl: aws eks update-kubeconfig --name {name} --region {region}")
|
732
|
+
console.print(f" 2. Verify connection: kubectl get svc")
|
733
|
+
console.print(f" 3. Deploy applications: k8s-helper apply <app-name> <image>")
|
716
734
|
else:
|
717
735
|
console.print("❌ Timeout waiting for cluster to become active")
|
718
736
|
else:
|
719
|
-
console.print("💡 Use 'aws eks update-kubeconfig --name {name} --region {region}' to configure kubectl")
|
737
|
+
console.print(f"💡 Use 'aws eks update-kubeconfig --name {name} --region {region}' to configure kubectl")
|
720
738
|
|
721
739
|
except Exception as e:
|
722
|
-
|
740
|
+
error_message = str(e)
|
741
|
+
console.print(f"❌ Failed to create EKS cluster: {error_message}")
|
742
|
+
|
743
|
+
# Provide helpful guidance based on error type
|
744
|
+
if "Need at least 2 subnets" in error_message:
|
745
|
+
console.print("\n🛠️ Troubleshooting:")
|
746
|
+
console.print(" • EKS requires subnets in at least 2 availability zones")
|
747
|
+
console.print(" • Check your VPC configuration in the AWS Console")
|
748
|
+
console.print(" • Ensure you have subnets in different AZs")
|
749
|
+
console.print(" • The tool will attempt to create subnets if none exist")
|
750
|
+
elif "credentials not found" in error_message:
|
751
|
+
console.print("\n🛠️ Troubleshooting:")
|
752
|
+
console.print(" • Configure AWS credentials: aws configure")
|
753
|
+
console.print(" • Or set environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY")
|
754
|
+
console.print(" • Ensure you have EKS permissions")
|
755
|
+
elif "VPC" in error_message:
|
756
|
+
console.print("\n🛠️ Troubleshooting:")
|
757
|
+
console.print(" • Check your VPC configuration")
|
758
|
+
console.print(" • Ensure you have a default VPC or create one")
|
759
|
+
console.print(" • Verify subnet CIDR ranges don't overlap")
|
723
760
|
|
724
761
|
|
725
762
|
# ======================
|
@@ -74,12 +74,16 @@ class EKSClient:
|
|
74
74
|
resourcesVpcConfig={
|
75
75
|
'subnetIds': subnets,
|
76
76
|
'securityGroupIds': security_groups or [],
|
77
|
-
'
|
78
|
-
'
|
77
|
+
'endpointPublicAccess': True,
|
78
|
+
'endpointPrivateAccess': True
|
79
79
|
},
|
80
80
|
logging={
|
81
|
-
'
|
82
|
-
|
81
|
+
'clusterLogging': [
|
82
|
+
{
|
83
|
+
'types': ['api', 'audit', 'authenticator', 'controllerManager', 'scheduler'],
|
84
|
+
'enabled': True
|
85
|
+
}
|
86
|
+
]
|
83
87
|
}
|
84
88
|
)
|
85
89
|
|
@@ -106,22 +110,110 @@ class EKSClient:
|
|
106
110
|
raise Exception(f"Failed to create EKS cluster: {e}")
|
107
111
|
|
108
112
|
def _get_default_subnets(self) -> List[str]:
|
109
|
-
"""Get default subnets for EKS cluster"""
|
113
|
+
"""Get default subnets for EKS cluster from different AZs"""
|
110
114
|
try:
|
111
115
|
response = self.ec2_client.describe_subnets()
|
112
|
-
|
116
|
+
|
117
|
+
# Group subnets by availability zone
|
118
|
+
subnets_by_az = {}
|
113
119
|
for subnet in response['Subnets']:
|
114
120
|
if subnet['State'] == 'available':
|
115
|
-
|
121
|
+
az = subnet['AvailabilityZone']
|
122
|
+
if az not in subnets_by_az:
|
123
|
+
subnets_by_az[az] = []
|
124
|
+
subnets_by_az[az].append(subnet['SubnetId'])
|
125
|
+
|
126
|
+
# Get at least 2 subnets from different AZs
|
127
|
+
selected_subnets = []
|
128
|
+
for az, subnet_ids in subnets_by_az.items():
|
129
|
+
if len(selected_subnets) < 2:
|
130
|
+
selected_subnets.append(subnet_ids[0]) # Take first subnet from each AZ
|
116
131
|
|
117
|
-
if len(
|
118
|
-
|
132
|
+
if len(selected_subnets) < 2:
|
133
|
+
# If we don't have subnets in 2 different AZs, let's create them
|
134
|
+
selected_subnets = self._create_default_vpc_subnets()
|
119
135
|
|
120
|
-
return
|
136
|
+
return selected_subnets
|
121
137
|
|
122
138
|
except ClientError as e:
|
123
139
|
raise Exception(f"Failed to get default subnets: {e}")
|
124
140
|
|
141
|
+
def _create_default_vpc_subnets(self) -> List[str]:
|
142
|
+
"""Create default VPC and subnets for EKS if none exist"""
|
143
|
+
try:
|
144
|
+
# Get default VPC
|
145
|
+
vpcs = self.ec2_client.describe_vpcs(Filters=[{'Name': 'isDefault', 'Values': ['true']}])
|
146
|
+
if not vpcs['Vpcs']:
|
147
|
+
raise Exception("No default VPC found. Please create subnets manually or set up a VPC.")
|
148
|
+
|
149
|
+
vpc_id = vpcs['Vpcs'][0]['VpcId']
|
150
|
+
|
151
|
+
# Get available AZs
|
152
|
+
azs = self.ec2_client.describe_availability_zones()
|
153
|
+
if len(azs['AvailabilityZones']) < 2:
|
154
|
+
raise Exception("Need at least 2 availability zones for EKS cluster")
|
155
|
+
|
156
|
+
# Create subnets in first 2 AZs
|
157
|
+
subnet_ids = []
|
158
|
+
for i, az in enumerate(azs['AvailabilityZones'][:2]):
|
159
|
+
cidr = f"172.31.{i * 16}.0/20" # Create non-overlapping CIDR blocks
|
160
|
+
|
161
|
+
try:
|
162
|
+
response = self.ec2_client.create_subnet(
|
163
|
+
VpcId=vpc_id,
|
164
|
+
CidrBlock=cidr,
|
165
|
+
AvailabilityZone=az['ZoneName']
|
166
|
+
)
|
167
|
+
subnet_id = response['Subnet']['SubnetId']
|
168
|
+
subnet_ids.append(subnet_id)
|
169
|
+
|
170
|
+
# Enable auto-assign public IP
|
171
|
+
self.ec2_client.modify_subnet_attribute(
|
172
|
+
SubnetId=subnet_id,
|
173
|
+
MapPublicIpOnLaunch={'Value': True}
|
174
|
+
)
|
175
|
+
|
176
|
+
# Tag the subnet
|
177
|
+
self.ec2_client.create_tags(
|
178
|
+
Resources=[subnet_id],
|
179
|
+
Tags=[
|
180
|
+
{'Key': 'Name', 'Value': f'eks-subnet-{az["ZoneName"]}'},
|
181
|
+
{'Key': 'kubernetes.io/role/elb', 'Value': '1'}
|
182
|
+
]
|
183
|
+
)
|
184
|
+
|
185
|
+
except ClientError as e:
|
186
|
+
if e.response['Error']['Code'] == 'InvalidVpc.Range':
|
187
|
+
# Try a different CIDR range
|
188
|
+
cidr = f"10.0.{i}.0/24"
|
189
|
+
response = self.ec2_client.create_subnet(
|
190
|
+
VpcId=vpc_id,
|
191
|
+
CidrBlock=cidr,
|
192
|
+
AvailabilityZone=az['ZoneName']
|
193
|
+
)
|
194
|
+
subnet_id = response['Subnet']['SubnetId']
|
195
|
+
subnet_ids.append(subnet_id)
|
196
|
+
|
197
|
+
# Enable auto-assign public IP
|
198
|
+
self.ec2_client.modify_subnet_attribute(
|
199
|
+
SubnetId=subnet_id,
|
200
|
+
MapPublicIpOnLaunch={'Value': True}
|
201
|
+
)
|
202
|
+
|
203
|
+
# Tag the subnet
|
204
|
+
self.ec2_client.create_tags(
|
205
|
+
Resources=[subnet_id],
|
206
|
+
Tags=[
|
207
|
+
{'Key': 'Name', 'Value': f'eks-subnet-{az["ZoneName"]}'},
|
208
|
+
{'Key': 'kubernetes.io/role/elb', 'Value': '1'}
|
209
|
+
]
|
210
|
+
)
|
211
|
+
|
212
|
+
return subnet_ids
|
213
|
+
|
214
|
+
except ClientError as e:
|
215
|
+
raise Exception(f"Failed to create default subnets: {e}")
|
216
|
+
|
125
217
|
def _create_or_get_cluster_role(self) -> str:
|
126
218
|
"""Create or get IAM role for EKS cluster"""
|
127
219
|
role_name = "eks-cluster-role"
|
@@ -179,7 +271,7 @@ class EKSClient:
|
|
179
271
|
'status': cluster['status'],
|
180
272
|
'endpoint': cluster.get('endpoint', 'Not available'),
|
181
273
|
'version': cluster['version'],
|
182
|
-
'platform_version': cluster
|
274
|
+
'platform_version': cluster.get('platformVersion', 'Not available'),
|
183
275
|
'created_at': cluster['createdAt'],
|
184
276
|
'arn': cluster['arn']
|
185
277
|
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{k8s_helper_cli-0.2.1 → k8s_helper_cli-0.2.3}/src/k8s_helper_cli.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|