Skip to content

Commit

Permalink
Merge pull request #20070 from carbonin/orchestrator_add_owner_reference
Browse files Browse the repository at this point in the history
Add an owner reference to the orchestrator pod for all created objects

(cherry picked from commit 1f07002)
  • Loading branch information
Fryguy authored and simaishi committed Apr 16, 2020
1 parent d441ba1 commit 79cf12f
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions lib/container_orchestrator/object_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ module ObjectDefinition
def deployment_definition(name)
{
:metadata => {
:name => name,
:labels => {:app => app_name},
:namespace => my_namespace,
:name => name,
:labels => {:app => app_name},
:namespace => my_namespace,
:ownerReferences => owner_references
},
:spec => {
:selector => {:matchLabels => {:name => name}},
Expand All @@ -30,9 +31,10 @@ def deployment_definition(name)
def service_definition(name, selector, port)
{
:metadata => {
:name => name,
:labels => {:app => app_name},
:namespace => my_namespace
:name => name,
:labels => {:app => app_name},
:namespace => my_namespace,
:ownerReferences => owner_references
},
:spec => {
:selector => selector,
Expand All @@ -48,9 +50,10 @@ def service_definition(name, selector, port)
def secret_definition(name, string_data)
{
:metadata => {
:name => name,
:labels => {:app => app_name},
:namespace => my_namespace
:name => name,
:labels => {:app => app_name},
:namespace => my_namespace,
:ownerReferences => owner_references
},
:stringData => string_data
}
Expand Down Expand Up @@ -101,5 +104,16 @@ def my_namespace
def app_name
ENV["APP_NAME"]
end

def owner_references
[{
:apiVersion => "v1",
:blockOwnerDeletion => true,
:controller => true,
:kind => "Pod",
:name => ENV["POD_NAME"],
:uid => ENV["POD_UID"]
}]
end
end
end

0 comments on commit 79cf12f

Please sign in to comment.