Skip to content
Snippets Groups Projects

Automatically configure Kubernetes Service

Merged Kamil Trzciński requested to merge configure-kubernetes-service into master

This change makes to read in-cluster credentials and put them into Kubernetes Service template, allowing to fulfill story described here: https://gitlab.com/gitlab-org/gitlab-ce/issues/28888. This in order to work, requires GitLab 9.1.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/28888

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • This also cleans up the code-for-rails content to be much more manageable.

  • merged

  • Jason Plum mentioned in commit f0f07c3f

    mentioned in commit f0f07c3f

  • Yeah, much cleaner.

  • @ayufan Not sure if this is real or not, but this isn't working in my helm chart version. I copied verbatim. The KubernetesService isn't being created. When I run from the rails console, the command generates an object, but doesn't seem to save it. I'm really not sure why, since first_or_create is what all the other entries use, and it works fine to save the object. And there's no errors to indicate why it wouldn't be saving.

  • irb(main):004:0> KubernetesService.where(template: true).first_or_create(
    irb(main):005:1*               active: true,
    irb(main):006:1*               api_url: "https://#{ENV["KUBERNETES_SERVICE_HOST"]}:#{ENV["KUBERNETES_SERVICE_PORT"]}",
    irb(main):007:1*               token: File.read("/var/run/secrets/kubernetes.io/serviceaccount/token"),
    irb(main):008:1*               ca_pem: File.read("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"))
    => #<KubernetesService id: nil, type: "KubernetesService", title: nil, project_id: nil, created_at: nil, updated_at: nil, active: true, properties: {"api_url"=>"https://10.3.240.1:443", "token"=>"redacted", "ca_pem"=>"-----BEGIN CERTIFICATE-----\nredacted\n-----END CERTIFICATE-----\n"}, template: true, push_events: true, issues_events: true, merge_requests_events: true, tag_push_events: true, note_events: true, build_events: true, category: "deployment", default: false, wiki_page_events: true, pipeline_events: true, confidential_issues_events: true, commit_events: true>
    irb(main):009:0> KubernetesService.first
    => nil
  • I just realized it might be because in 9.0, the namespace is required, so it's failing validation, despite no error message. I'm not using rc1 yet.

  • Yep, that's it. Adding a namespace makes it succeed. So, hopefully this is a non-issue for 9.1.

Please register or sign in to reply
Loading