Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • gitlab-runner gitlab-runner
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 972
    • Issues 972
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Jira
    • Jira
  • Merge requests 88
    • Merge requests 88
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Environments
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
  • Activity
  • Create a new issue
  • Jobs
  • Issue Boards
Collapse sidebar

Do not update/delete: Banner broadcast message test data

Do not update/delete: Notification broadcast message test data

  • GitLab.orgGitLab.org
  • gitlab-runnergitlab-runner
  • Issues
  • #1876
Closed
Open
Issue created Nov 14, 2016 by username-removed-330886@jan4

kubernetes-executor should allow specifying volumes (HostPath, Secrets)

The docker executor has the option to mount directories from the Host, but the kubernetes executor doesn't. Additionally it would be nice to specify Secrets, which hold sensitive information (e.g. dockerhub credentials, kubeconfig credentials).

I have hacked it in, but the real solution should be to make it configurable:

diff --git a/executors/kubernetes/executor_kubernetes.go b/executors/kubernetes/executor_kubernetes.go
index dc011fa..18d2faa 100644
--- a/executors/kubernetes/executor_kubernetes.go
+++ b/executors/kubernetes/executor_kubernetes.go
@@ -138,6 +138,18 @@ func (s *executor) buildContainer(name, image string, limits api.ResourceList, c
                                Name:      "repo",
                                MountPath: strings.Join(path, "/"),
                        },
+                       api.VolumeMount{
+                               Name:      "docker-socket",
+                               MountPath: "/var/run/docker.sock",
+                       },
+                       api.VolumeMount{
+                               Name:      "docker-cred",
+                               MountPath: "/root/.docker/",
+                       },
+                       api.VolumeMount{
+                               Name:      "kube-cred",
+                               MountPath: "/root/.kube/",
+                       },
                },
                SecurityContext: &api.SecurityContext{
                        Privileged: &privileged,
@@ -167,6 +179,30 @@ func (s *executor) setupBuildPod() error {
                                                EmptyDir: &api.EmptyDirVolumeSource{},
                                        },
                                },
+                               api.Volume{
+                                       Name: "docker-socket",
+                                       VolumeSource: api.VolumeSource{
+                                               HostPath: &api.HostPathVolumeSource{
+                                                       Path: "/var/run/docker.sock",
+                                               },
+                                       },
+                               },
+                               api.Volume{
+                                       Name: "docker-cred",
+                                       VolumeSource: api.VolumeSource{
+                                               Secret: &api.SecretVolumeSource{
+                                                       SecretName: "docker-cred",
+                                               },
+                                       },
+                               },
+                               api.Volume{
+                                       Name: "kube-cred",
+                                       VolumeSource: api.VolumeSource{
+                                               Secret: &api.SecretVolumeSource{
+                                                       SecretName: "kube-cred",
+                                               },
+                                       },
+                               },
                        },
                        RestartPolicy: api.RestartPolicyNever,
                        Containers: append([]api.Container{

The image is availabe on dockerhub: willies/gitlab-runner:1.7.1_kube.3 (https://hub.docker.com/r/willies/gitlab-runner/)

Some instructions and a demo how to use it are here: https://github.com/janwillies/taw16-k8s-cd

Assignee
Assign to
Time tracking