Can't git clone into Kubernetes gitRepo volume

3/3/2017

I have a YAML file that I use to create a Deployment in Kubernetes which includes:

    volumeMounts:
    - name: git-volume
      mountPath: /code
  volumes:
  - name: git-volume
    gitRepo:
      repository: "git@bitbucket.org:organization/bot.git"
      revision: "b686122a44aa271117b602e4eba4cc02f5e56044"

I have a public Bitbucket Git repo (I can view it without logging in to Bitbucket).

I get this error when starting the Deployment in Kubernetes:

failed to exec 'git clone git@bitbucket.org:organization/bot.git': Cloning into 'bot'... Could not create directory '/root/.ssh'.
 Failed to add the host to the list of known hosts (/root/.ssh/known_hosts).
 Permission denied (publickey).
 fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. : exit status 128

How can I get this repo to clone?

-- skunkwerk
git
kubernetes

1 Answer

3/3/2017

Solution is to switch to HTTPS instead of SSH (available in the dropdown in the top-right section of Bitbucket).

Ie:

https://organization@bitbucket.org/organization/bot.git

-- skunkwerk
Source: StackOverflow