Skip to content

Commit

Permalink
fix(k8s): cluster option preserves kubectl context
Browse files Browse the repository at this point in the history
  • Loading branch information
nicknovitski committed Dec 13, 2024
1 parent 57c882a commit 5321a3a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions shell-modules/k8s.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ in
];
gcloud.enable = true;
gcloud.extra-components = [ "gke-gcloud-auth-plugin" ];
interactiveShellHook = lib.optionalString (
cfg.cluster != null
) "gcloud container clusters get-credentials ${cfg.cluster} --region ${cfg.region}";
interactiveShellHook = lib.optionalString (cfg.cluster != null) ''
kubectlContext="$(kubectl config current-context)"
gcloud container clusters get-credentials ${cfg.cluster} --region ${cfg.region}
kubectl config use "$kubectlContext"
'';
};
}

0 comments on commit 5321a3a

Please sign in to comment.