SAP / jenkins-library

Jenkins shared library for Continuous Delivery pipelines.
https://www.project-piper.io
Apache License 2.0
781 stars 594 forks source link

Container based application with K8S deploy error #4373

Closed Architgoel4 closed 1 year ago

Architgoel4 commented 1 year ago

Hi, I am trying to deploy an app to Kyma using the CICD service. It's failing at the deploy step as Kyma requires oidc-plugin with the below error. Is there a way we can pre-hook and run kubectl krew install oidc-login?

I did try with the Run First in Stage before the Acceptance stage with this command kubectl krew install oidc-login but I get this error then [2023-05-24T21:46:25.645Z] [INFO] Customer exit starts here (runFirst/Acceptance) [Pipeline] sh [2023-05-24T21:46:26.542Z] + kubectl krew install oidc-login [2023-05-24T21:46:26.558Z] /home/jenkins/agent/workspace/CPQ2-KYMA-HANA-TEST@tmp/durable-3d276c3e/script.sh: line 1: kubectl: not found [Pipeline] echo [2023-05-24T21:46:26.867Z] Error encoutered during customer-exit: 'script returned exit code 127' [Pipeline] echo [2023-05-24T21:46:27.405Z] [INFO] Customer exit ends here (runFirst/Acceptance) [Pipeline] sh

Using KUBECONFIG environment for authentication. [2023-05-24T21:34:32.214Z] info kubernetesDeploy - No/incomplete container registry credentials provided: skipping secret creation [2023-05-24T21:34:32.229Z] info kubernetesDeploy - running command: kubectl --insecure-skip-tls-verify=true --namespace=kyma-cps2 apply --filename ./k8s/deployment.yml [2023-05-24T21:34:32.244Z] info kubernetesDeploy - Unable to connect to the server: getting credentials: exec: executable kubectl-oidc_login not found [2023-05-24T21:34:32.257Z] info kubernetesDeploy - [2023-05-24T21:34:32.275Z] info kubernetesDeploy - It looks like you are trying to use a client-go credential plugin that is not installed. [2023-05-24T21:34:32.289Z] info kubernetesDeploy - [2023-05-24T21:34:32.306Z] info kubernetesDeploy - To learn more about this feature, consult the documentation available at: [2023-05-24T21:34:32.316Z] info kubernetesDeploy - https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins [2023-05-24T21:34:32.329Z] info kubernetesDeploy - [2023-05-24T21:34:32.342Z] info kubernetesDeploy - kubelogin plugin is required to proceed with authentication [2023-05-24T21:34:32.355Z] info kubernetesDeploy - # Homebrew (macOS and Linux) [2023-05-24T21:34:32.367Z] info kubernetesDeploy - brew install int128/kubelogin/kubelogin [2023-05-24T21:34:32.378Z] info kubernetesDeploy - [2023-05-24T21:34:32.391Z] info kubernetesDeploy - # Krew (macOS, Linux, Windows and ARM) [2023-05-24T21:34:32.404Z] info kubernetesDeploy - kubectl krew install oidc-login [2023-05-24T21:34:32.415Z] info kubernetesDeploy - [2023-05-24T21:34:32.447Z] info kubernetesDeploy - # Chocolatey (Windows) [2023-05-24T21:34:32.462Z] info kubernetesDeploy - choco install kubelogin [2023-05-24T21:34:32.475Z] info kubernetesDeploy - fatal error: errorDetails{"category":"undefined","correlationId":"n/a","error":"running command 'kubectl' failed: cmd.Run() failed: exit status 1","library":"SAP/jenkins-library","message":"Deployment with kubectl failed.","result":"failure","stepName":"kubernetesDeploy","time":"2023-05-24T21:34:32.193536568Z"} [2023-05-24T21:34:32.769Z] fatal kubernetesDeploy - Deployment with kubectl failed. - running command 'kubectl' failed: cmd.Run() failed: exit status 1

Architgoel4 commented 1 year ago

@SAP/jenkins-library-team Any help on this?

anilkeshav27 commented 1 year ago

oidc-login indicates a personal user is being for the k8s login. oidc login will not work in a ci/cd environment since oidc login requires a browser based authentication which is not possible for ci/cd environment.

please use a k8s service account that has the standard login and not using the oidc plugin.

Architgoel4 commented 1 year ago

@anilkeshav27 thanks I overlooked the different kubeconfig file. Thanks!