Commit 337e676
authored
Check if Kubernetes resources exist before creating them in XPK setup (#1195)
* Check if Kubernetes resources exist before creating them in XPK setup
In GKE clusters with restricted permissions, users might have read access to Roles/ServiceAccounts/RoleBindings but not create access. XPK was previously using try-create-catch-409 logic, which causes 403 Forbidden errors if the user lacks create permission, even if the resource already exists.
This change implements a 'check before create' pattern for ServiceAccount, Role, and RoleBinding creation in cluster.py. It checks if the resource exists first (using GET), and only attempts to create it (POST) if it doesn't exist. This allows administrators to pre-create these resources and lets developers run XPK without needing elevated creation permissions.
* Format cluster.py with pyink1 parent 0f92c2b commit 337e676
1 file changed
Lines changed: 45 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
447 | 447 | | |
448 | 448 | | |
449 | 449 | | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
450 | 461 | | |
451 | 462 | | |
452 | 463 | | |
453 | 464 | | |
454 | 465 | | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
460 | 475 | | |
461 | 476 | | |
462 | 477 | | |
| |||
466 | 481 | | |
467 | 482 | | |
468 | 483 | | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
469 | 493 | | |
470 | 494 | | |
471 | 495 | | |
| |||
510 | 534 | | |
511 | 535 | | |
512 | 536 | | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
513 | 551 | | |
514 | 552 | | |
515 | 553 | | |
| |||
526 | 564 | | |
527 | 565 | | |
528 | 566 | | |
529 | | - | |
| 567 | + | |
530 | 568 | | |
531 | 569 | | |
532 | 570 | | |
533 | 571 | | |
534 | 572 | | |
535 | 573 | | |
536 | | - | |
537 | | - | |
538 | | - | |
| 574 | + | |
539 | 575 | | |
540 | 576 | | |
541 | 577 | | |
| |||
0 commit comments