Fix commands for kubectl >= 1.12
The `--username` and `--password` top level options have been removed. Fortunately we have a backwards compatible way of setting the credentials via `kubectl config set-credentials <name>`, and using the `--user <name>` top level option which is available at least in 1.10 (and possibly farther back).
This commit is contained in:
parent
64c305e446
commit
c5522c7d44
|
@ -34,7 +34,14 @@ module QA
|
|||
CMD
|
||||
|
||||
@api_url = `kubectl config view --minify -o jsonpath='{.clusters[].cluster.server}'`
|
||||
@master_auth = JSON.parse(`gcloud container clusters describe #{cluster_name} --zone #{Runtime::Env.gcloud_zone} --format 'json(masterAuth.username, masterAuth.password)'`)
|
||||
|
||||
@admin_user = "#{cluster_name}-admin"
|
||||
master_auth = JSON.parse(`gcloud container clusters describe #{cluster_name} --zone #{Runtime::Env.gcloud_zone} --format 'json(masterAuth.username, masterAuth.password)'`)
|
||||
shell <<~CMD.tr("\n", ' ')
|
||||
kubectl config set-credentials #{@admin_user}
|
||||
--username #{master_auth['masterAuth']['username']}
|
||||
--password #{master_auth['masterAuth']['password']}
|
||||
CMD
|
||||
|
||||
if rbac
|
||||
create_service_account
|
||||
|
@ -67,7 +74,7 @@ module QA
|
|||
|
||||
def create_service_account
|
||||
shell('kubectl create -f -', stdin_data: service_account)
|
||||
shell("kubectl --username #{@master_auth['masterAuth']['username']} --password #{@master_auth['masterAuth']['password']} create -f -", stdin_data: service_account_role_binding)
|
||||
shell("kubectl --user #{@admin_user} create -f -", stdin_data: service_account_role_binding)
|
||||
end
|
||||
|
||||
def service_account
|
||||
|
|
Loading…
Reference in New Issue