Skip to content

Commit cc0c550

Browse files
authored
Merge pull request #70 from svenvanhees/master
Support ingress tls configuration
2 parents e0db4eb + a462e7c commit cc0c550

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

docs/kinds/Ingress.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ $ingress = $cluster->ingress()
99
->setName('nginx')
1010
->setLabels(['tier' => 'backend'])
1111
->setSelectors(['app' => 'frontend'])
12+
->setTls([[
13+
'hosts' => [
14+
'test.com'
15+
],
16+
'secretName'=> 'verySecretName'
17+
]])
1218
->setRules([[
1319
'host' => 'nginx.test.com',
1420
'http' => [

src/Kinds/K8sIngress.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,25 @@ public function getRules(): array
8181
{
8282
return $this->getSpec('rules', []);
8383
}
84+
85+
/**
86+
* Set the spec tls.
87+
*
88+
* @param array $rules
89+
* @return $this
90+
*/
91+
public function setTls(array $tlsData = [])
92+
{
93+
return $this->setSpec('tls', $tlsData);
94+
}
95+
96+
/**
97+
* Get the tls spec.
98+
*
99+
* @return array
100+
*/
101+
public function getTls(): array
102+
{
103+
return $this->getSpec('tls', []);
104+
}
84105
}

tests/IngressTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,33 @@ class IngressTest extends TestCase
2727
],
2828
]];
2929

30+
/**
31+
* The default testing tls.
32+
*
33+
* @var array
34+
*/
35+
protected static $tls = [[
36+
'hosts' => [
37+
'nginx.test.com',
38+
],
39+
'secretName' => 'verySecretName',
40+
]];
41+
3042
public function test_ingress_build()
3143
{
3244
$ing = $this->cluster->ingress()
3345
->setName('nginx')
3446
->setLabels(['tier' => 'backend'])
3547
->setAnnotations(['nginx/ann' => 'yes'])
48+
->setTls(self::$tls)
3649
->addRules(self::$rules)
3750
->setRules(self::$rules);
3851

3952
$this->assertEquals('networking.k8s.io/v1beta1', $ing->getApiVersion());
4053
$this->assertEquals('nginx', $ing->getName());
4154
$this->assertEquals(['tier' => 'backend'], $ing->getLabels());
4255
$this->assertEquals(['nginx/ann' => 'yes'], $ing->getAnnotations());
56+
$this->assertEquals(self::$tls, $ing->getTls());
4357
$this->assertEquals(self::$rules, $ing->getRules());
4458
}
4559

@@ -71,6 +85,7 @@ public function runCreationTests()
7185
->setName('nginx')
7286
->setLabels(['tier' => 'backend'])
7387
->setAnnotations(['nginx/ann' => 'yes'])
88+
->setTls(self::$tls)
7489
->setRules(self::$rules);
7590

7691
$this->assertFalse($ing->isSynced());
@@ -87,6 +102,7 @@ public function runCreationTests()
87102
$this->assertEquals('nginx', $ing->getName());
88103
$this->assertEquals(['tier' => 'backend'], $ing->getLabels());
89104
$this->assertEquals(['nginx/ann' => 'yes'], $ing->getAnnotations());
105+
$this->assertEquals(self::$tls, $ing->getTls());
90106
$this->assertEquals(self::$rules, $ing->getRules());
91107
}
92108

@@ -134,6 +150,7 @@ public function runUpdateTests()
134150
$this->assertEquals('nginx', $ing->getName());
135151
$this->assertEquals(['tier' => 'backend'], $ing->getLabels());
136152
$this->assertEquals([], $ing->getAnnotations());
153+
$this->assertEquals(self::$tls, $ing->getTls());
137154
$this->assertEquals(self::$rules, $ing->getRules());
138155
}
139156

0 commit comments

Comments
 (0)