-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathistio.py
33 lines (23 loc) · 902 Bytes
/
istio.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import logging
logger = logging.getLogger(__name__)
from .common import KubernetesResource, kgenlib
class IstioPolicy(KubernetesResource):
kind: str = "IstioPolicy"
api_version: str = "authentication.istio.io/v1alpha1"
def body(self):
super().body()
config = self.config
name = self.name
self.root.spec.origins = config.istio_policy.policies.origins
self.root.spec.principalBinding = "USE_ORIGIN"
self.root.spec.targets = [{"name": name}]
@kgenlib.register_generator(path="generators.istio.gateway")
class IstioGatewayGenerator(kgenlib.BaseStore):
def body(self):
self.add(IstioGateway(name=self.id, config=self.config))
class IstioGateway(KubernetesResource):
kind: str = "Gateway"
api_version: str = "networking.istio.io/v1"
def body(self):
super().body()
self.root.spec = self.config.spec