Skip to content

Commit 08628e7

Browse files
authored
Merge pull request #193 from pfeifferj/chore-release-0.3.58
feat: consolidate vpc constructor
2 parents 779786f + 337a46e commit 08628e7

File tree

28 files changed

+2045
-235
lines changed

28 files changed

+2045
-235
lines changed

charts/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ keywords:
1616
- iks
1717
- nodepool
1818
- custom-resources
19-
home: https://github.com/pfeifferj/karpenter-ibm-cloud
19+
home: https://github.com/pfeifferj/karpenter-provider-ibm-cloud
2020
icon: https://repository-images.githubusercontent.com/278480393/dab059c8-caa1-4b55-aaa7-3d30e47a5616
2121
sources:
22-
- https://github.com/pfeifferj/karpenter-ibm-cloud
22+
- https://github.com/pfeifferj/karpenter-provider-ibm-cloud
2323
annotations:
2424
"helm.sh/resource-policy": keep

cmd/controller/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ limitations under the License.
1616
package main
1717

1818
import (
19+
"os"
20+
1921
ibmcloud "github.com/pfeifferj/karpenter-provider-ibm-cloud/pkg/cloudprovider"
2022
"github.com/pfeifferj/karpenter-provider-ibm-cloud/pkg/controllers"
2123
"github.com/pfeifferj/karpenter-provider-ibm-cloud/pkg/operator"
2224
"github.com/pfeifferj/karpenter-provider-ibm-cloud/pkg/operator/options"
2325

26+
"sigs.k8s.io/controller-runtime/pkg/log"
2427
"sigs.k8s.io/karpenter/pkg/cloudprovider/metrics"
2528
corecontrollers "sigs.k8s.io/karpenter/pkg/controllers"
2629
"sigs.k8s.io/karpenter/pkg/controllers/state"
@@ -63,7 +66,8 @@ func main() {
6366

6467
// Register bootstrap controller
6568
if err := controllers.RegisterBootstrapController(op.Manager); err != nil {
66-
panic(err)
69+
log.FromContext(ctx).Error(err, "failed to register bootstrap controller")
70+
os.Exit(1)
6771
}
6872

6973
// Register controllers using the proper operator pattern

docs/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ helm install karpenter karpenter-ibm/karpenter-ibm \
100100
--namespace karpenter \
101101
--create-namespace \
102102
--set credentials.region="us-south" \
103-
--set credentials.ibm_api_key="your-general-api-key" \
104-
--set credentials.vpc_api_key="your-vpc-api-key"
103+
--set credentials.ibmApiKey="your-general-api-key" \
104+
--set credentials.vpcApiKey="your-vpc-api-key"
105105
```
106106

107107
### Step 2: Verify Installation

docs/iks-integration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ ibmcloud ks cluster get --cluster <cluster-id>
3535
kubectl create namespace karpenter
3636

3737
kubectl create secret generic karpenter-ibm-credentials \
38-
--from-literal=api-key="your-general-api-key" \
39-
--from-literal=vpc-api-key="your-vpc-api-key" \
38+
--from-literal=ibmApiKey="your-general-api-key" \
39+
--from-literal=vpcApiKey="your-vpc-api-key" \
4040
--namespace karpenter
4141

4242
# Install via Helm
43-
helm repo add karpenter-ibm https://pfeifferj.github.io/karpenter-provider-ibm-cloud
43+
helm repo add karpenter-ibm https://karpenter-ibm.sh
4444
helm repo update
4545
helm install karpenter karpenter-ibm/karpenter-ibm \
4646
--namespace karpenter \

docs/troubleshooting.md

Lines changed: 130 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,41 +58,144 @@ kubectl logs -n karpenter deployment/karpenter | grep "Starting Controller"
5858

5959
### Node Registration Issues
6060

61-
!!! error "Node failed to join cluster"
62-
**Most Common Issue - Wrong API Server Endpoint:**
63-
```bash
64-
# Symptoms: kubelet timeouts, nodes never register
65-
# Error: "dial tcp 10.243.65.4:6443: i/o timeout"
61+
!!! error "Nodes not joining cluster after provisioning"
62+
This is often caused by a chain of issues. Work through this systematic checklist:
6663

67-
# 1. Check what endpoint kubelet is trying to reach
68-
ssh ubuntu@INSTANCE_IP "cat /var/lib/kubelet/bootstrap-kubeconfig | grep server"
64+
#### 1. Verify Instance Creation
6965

70-
# 2. Find correct internal API endpoint
71-
kubectl get endpointslice -n default -l kubernetes.io/service-name=kubernetes
66+
```bash
67+
# Check if instances are being created
68+
ibmcloud is instances --output json | jq '.[] | select(.name | contains("nodepool"))'
7269

73-
# 3. Update NodeClass with correct INTERNAL endpoint
74-
kubectl patch ibmnodeclass YOUR-NODECLASS --type='merge' \
75-
-p='{"spec":{"apiServerEndpoint":"https://INTERNAL-IP:6443"}}'
76-
```
70+
# Check NodeClaim status
71+
kubectl get nodeclaims -o wide
72+
kubectl describe nodeclaim NODECLAIM_NAME
73+
```
7774

78-
**Other Common Causes:**
75+
**Expected:** Instance status `running`, NodeClaim shows `Launched: True`
7976

80-
- VNI (Virtual Network Interface) not configured properly (v0.3.53+ required)
81-
- Bootstrap token expiration
82-
- Network connectivity problems
77+
#### 2. Check Network Connectivity (Most Common Issue)
8378

84-
**Debug steps:**
85-
```bash
86-
# Check bootstrap logs on instance
87-
ssh ubuntu@INSTANCE_IP "sudo journalctl -u cloud-final"
79+
**Step 2a: Verify Subnet Placement**
80+
```bash
81+
# Find which subnet your cluster nodes are in
82+
kubectl get nodes -o wide # Note the INTERNAL-IP range
8883

89-
# Check kubelet status and errors
90-
ssh ubuntu@INSTANCE_IP "sudo systemctl status kubelet"
91-
ssh ubuntu@INSTANCE_IP "sudo journalctl -u kubelet --no-pager -n 50"
84+
# Check if Karpenter nodes are in the same subnet
85+
ibmcloud is instance INSTANCE_ID --output json | jq '.primary_network_interface.subnet'
9286

93-
# Test API server connectivity from node
94-
ssh ubuntu@INSTANCE_IP "curl -k -m 10 https://API-SERVER-IP:6443/healthz"
95-
```
87+
# If different subnets, nodes may be network-isolated!
88+
```
89+
90+
**Step 2b: Verify API Server Endpoint Configuration**
91+
```bash
92+
# Find the INTERNAL API endpoint (not external!)
93+
kubectl get endpoints kubernetes -o yaml
94+
# OR
95+
kubectl get endpointslice -n default -l kubernetes.io/service-name=kubernetes
96+
97+
# Check what's configured in IBMNodeClass
98+
kubectl get ibmnodeclass YOUR-NODECLASS -o yaml | grep apiServerEndpoint
99+
100+
# Update if using external IP instead of internal
101+
kubectl patch ibmnodeclass YOUR-NODECLASS --type='merge' \
102+
-p='{"spec":{"apiServerEndpoint":"https://INTERNAL-IP:6443"}}'
103+
```
104+
105+
**Step 2c: Test Connectivity from Node**
106+
```bash
107+
# Attach floating IP for debugging
108+
109+
# Then SSH and test
110+
ssh -i ~/.ssh/eb root@FLOATING_IP
111+
112+
# Test network layers
113+
ping INTERNAL_API_IP # Test ICMP
114+
telnet INTERNAL_API_IP 6443 # Test TCP
115+
curl -k https://INTERNAL_API_IP:6443/healthz # Test HTTPS
116+
```
117+
118+
#### 3. Verify Security Groups
119+
120+
!!! danger "Security Group Requirements"
121+
Both worker and control plane security groups need proper rules for bidirectional communication.
122+
123+
**Required Security Group Rules:**
124+
125+
```bash
126+
# Check current security groups on instance
127+
ibmcloud is instance INSTANCE_ID --output json | \
128+
jq '.network_interfaces[0].security_groups'
129+
130+
# Worker Node Security Group needs:
131+
# Outbound rules
132+
- TCP 6443 to control plane subnet (Kubernetes API)
133+
- TCP 10250 to all nodes (Kubelet)
134+
- TCP/UDP 53 to 0.0.0.0/0 (DNS)
135+
- TCP 80,443 to 0.0.0.0/0 (Package downloads)
136+
137+
# Inbound rules
138+
- TCP 6443 from control plane (API server callbacks)
139+
- TCP 10250 from all nodes (Kubelet peer communication)
140+
141+
# Add missing rules example:
142+
ibmcloud is security-group-rule-add WORKER_SG_ID \
143+
outbound tcp --port-min 6443 --port-max 6443 \
144+
--remote CONTROL_PLANE_SUBNET_CIDR
145+
146+
ibmcloud is security-group-rule-add WORKER_SG_ID \
147+
inbound tcp --port-min 6443 --port-max 6443 \
148+
--remote CONTROL_PLANE_SUBNET_CIDR
149+
```
150+
151+
#### 4. Debug Bootstrap Process
152+
153+
**Check Cloud-Init Status:**
154+
```bash
155+
# SSH to node (after attaching floating IP)
156+
ssh -i ~/.ssh/eb root@FLOATING_IP
157+
158+
# Check cloud-init progress
159+
sudo cloud-init status --long
160+
161+
# View bootstrap logs
162+
sudo tail -100 /var/log/cloud-init.log
163+
sudo tail -100 /var/log/cloud-init-output.log
164+
sudo cat /var/log/karpenter-bootstrap.log
165+
166+
# Check if kubelet was installed
167+
sudo systemctl status kubelet
168+
sudo journalctl -u kubelet --no-pager -n 50
169+
```
170+
171+
**Common Bootstrap Issues:**
172+
- Package repository access blocked (check security groups for HTTP/HTTPS)
173+
- CNI conflicts (check for pre-existing CNI configurations)
174+
175+
#### 5. Verify IBMNodeClass Configuration
176+
177+
```bash
178+
# Check for common configuration issues
179+
kubectl get ibmnodeclass YOUR-NODECLASS -o yaml
180+
181+
# Key fields to verify:
182+
# - apiServerEndpoint: Must be INTERNAL cluster endpoint
183+
# - bootstrapMode: Should be "cloud-init" for VPC
184+
# - securityGroups: Must include proper security group IDs
185+
# - sshKeys: Must use SSH key IDs (r010-xxx format), not names
186+
```
187+
188+
#### 6. Check Resource Group Configuration
189+
190+
```bash
191+
# Verify instances are created in correct resource group
192+
ibmcloud is instances --output json | \
193+
jq '.[] | select(.name | contains("nodepool")) |
194+
{name: .name, resource_group: .resource_group.id}'
195+
196+
# Should match the resource group in IBMNodeClass
197+
kubectl get ibmnodeclass YOUR-NODECLASS -o yaml | grep resourceGroupID
198+
```
96199

97200
### Security Group Configuration
98201

docs/vpc-integration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ ibmcloud is images --visibility public --status available | grep ubuntu
4343
kubectl create namespace karpenter
4444

4545
kubectl create secret generic karpenter-ibm-credentials \
46-
--from-literal=api-key="your-general-api-key" \
47-
--from-literal=vpc-api-key="your-vpc-api-key" \
46+
--from-literal=ibmApiKey="your-general-api-key" \
47+
--from-literal=vpcApiKey="your-vpc-api-key" \
4848
--namespace karpenter
4949

5050
# Install via Helm
51-
helm repo add karpenter-ibm https://pfeifferj.github.io/karpenter-provider-ibm-cloud
51+
helm repo add karpenter-ibm https://karpenter-ibm.sh
5252
helm repo update
5353
helm install karpenter karpenter-ibm/karpenter-ibm \
5454
--namespace karpenter \

go.sum

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
github.com/IBM/go-sdk-core/v5 v5.20.1 h1:dzeyifh1kfRLw8VfAIIS5okZYuqLTqplPZP/Kcsgdlo=
22
github.com/IBM/go-sdk-core/v5 v5.20.1/go.mod h1:Q3BYO6iDA2zweQPDGbNTtqft5tDcEpm6RTuqMlPcvbw=
3-
github.com/IBM/platform-services-go-sdk v0.85.0 h1:JuoinnP9qMvnz5mIl574QWBd+wj6isG8NkrFM6mPdP0=
4-
github.com/IBM/platform-services-go-sdk v0.85.0/go.mod h1:aGD045m6I8pfcB77wft8w2cHqWOJjcM3YSSV55BX0Js=
53
github.com/IBM/platform-services-go-sdk v0.85.1 h1:lrBEeGaIajhSPMB6cPVAx53XTtVGrKOeA36gIXh2FYI=
64
github.com/IBM/platform-services-go-sdk v0.85.1/go.mod h1:aGD045m6I8pfcB77wft8w2cHqWOJjcM3YSSV55BX0Js=
75
github.com/IBM/vpc-go-sdk v0.70.1 h1:6NsbRkiA5gDNxe7cjNx8Pi1j9s0PlhwNQj29wsKZxAo=
@@ -132,8 +130,6 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
132130
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
133131
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
134132
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
135-
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
136-
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
137133
github.com/onsi/gomega v1.38.0 h1:c/WX+w8SLAinvuKKQFh77WEucCnPk4j2OTUr7lt7BeY=
138134
github.com/onsi/gomega v1.38.0/go.mod h1:OcXcwId0b9QsE7Y49u+BTrL4IdKOBOKnD6VQNTJEB6o=
139135
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
@@ -145,18 +141,12 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
145141
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
146142
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
147143
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
148-
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
149-
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
150144
github.com/prometheus/client_golang v1.23.0 h1:ust4zpdl9r4trLY/gSjlm07PuiBq2ynaXXlptpfy8Uc=
151145
github.com/prometheus/client_golang v1.23.0/go.mod h1:i/o0R9ByOnHX0McrTMTyhYvKE4haaf2mW08I+jGAjEE=
152146
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
153147
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
154-
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
155-
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
156148
github.com/prometheus/common v0.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2VzE=
157149
github.com/prometheus/common v0.65.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8=
158-
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
159-
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
160150
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
161151
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
162152
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
@@ -203,8 +193,6 @@ go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
203193
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
204194
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
205195
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
206-
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
207-
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
208196
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
209197
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
210198
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@@ -215,12 +203,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
215203
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
216204
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
217205
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
218-
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
219-
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
220206
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
221207
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
222-
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
223-
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
224208
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
225209
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
226210
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -300,8 +284,6 @@ sigs.k8s.io/controller-tools v0.18.0 h1:rGxGZCZTV2wJreeRgqVoWab/mfcumTMmSwKzoM9x
300284
sigs.k8s.io/controller-tools v0.18.0/go.mod h1:gLKoiGBriyNh+x1rWtUQnakUYEujErjXs9pf+x/8n1U=
301285
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE=
302286
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
303-
sigs.k8s.io/karpenter v1.6.0 h1:82SIWF3FIaTkD5WFx+2wjCqgkZK5m1CHY5p+uIu4ScI=
304-
sigs.k8s.io/karpenter v1.6.0/go.mod h1:AxCaeRjv1Pgw/Ff7vT4aqyXcg8v1UdBcfzWMCaKSVjA=
305287
sigs.k8s.io/karpenter v1.6.1 h1:ZAC802Prk/GyKoGUu0LuzEn9fFmJLfUtMfo64derQgw=
306288
sigs.k8s.io/karpenter v1.6.1/go.mod h1:AxCaeRjv1Pgw/Ff7vT4aqyXcg8v1UdBcfzWMCaKSVjA=
307289
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package constants
18+
19+
import (
20+
"testing"
21+
)
22+
23+
func TestGroupConstant(t *testing.T) {
24+
expected := "karpenter.ibm.sh"
25+
if Group != expected {
26+
t.Errorf("Group constant = %v, want %v", Group, expected)
27+
}
28+
}
29+
30+
func TestGroupConstantNotEmpty(t *testing.T) {
31+
if Group == "" {
32+
t.Error("Group constant should not be empty")
33+
}
34+
}

pkg/apis/group_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Copyright The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package apis
18+
19+
import (
20+
"testing"
21+
22+
"github.com/stretchr/testify/assert"
23+
)
24+
25+
func TestGroup(t *testing.T) {
26+
t.Run("Group constant is correctly defined", func(t *testing.T) {
27+
assert.Equal(t, "karpenter.ibm.sh", Group)
28+
assert.NotEmpty(t, Group)
29+
})
30+
31+
t.Run("Group follows Kubernetes API group naming convention", func(t *testing.T) {
32+
assert.Contains(t, Group, ".")
33+
assert.Contains(t, Group, "karpenter")
34+
assert.Contains(t, Group, "ibm")
35+
assert.NotContains(t, Group, " ")
36+
assert.NotContains(t, Group, "/")
37+
})
38+
}

0 commit comments

Comments
 (0)