3

How can I using kubectl cmd to get specific pod's commit sha1 like:

kubectl get git_commit_sha1 [pod_name]
Dave kam
  • 373
  • 1
  • 3
  • 5
  • I don't think you can get this directly; I wouldn't expect a given pod to have either the `git` tool or the `.git` directory, and for that matter it might use a source control system like Mercurial or Subversion instead. – David Maze Jun 08 '20 at 10:59

1 Answers1

1

There is no way to achieve what you want at the moment using kubectl. They only possible way would be if your docker image have git command built in. In that case you could use kubectl exec to get the information you want.

Example:

$ kubectl exec -ti podname -- git show

Alternatively, if you really think your idea makes sense and may be useful to more people, you can open a feature request on kubernetes github issues page.

Mark Watney
  • 5,268
  • 2
  • 11
  • 33