Skip to content

Commit

Permalink
Revert "remove ingress"
Browse files Browse the repository at this point in the history
This reverts commit f2d235d.
  • Loading branch information
manojn94 committed Mar 14, 2022
1 parent f2d235d commit 9c53123
Show file tree
Hide file tree
Showing 10 changed files with 278 additions and 2 deletions.
54 changes: 54 additions & 0 deletions docs/reference/associated-topology.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,58 @@ Example with removed object named `example`:
```
associatedTopology:
v1:ConfigMap:doc:example: null
```

Example with deployed Helm release named `example`:
```
associatedTopology:
Helm:doc:example:
id: Helm:doc:example
type: Helm
apps/v1:Deployment:doc:example-nginx-ingress-controlle:
id: dff72633-96c0-11ea-98ae-005056956986
type: apps/v1:Deployment
apps/v1:Deployment:doc:example-nginx-ingress-default-b:
id: dff8d818-96c0-11ea-98ae-005056956986
type: apps/v1:Deployment
rbac.authorization.k8s.io/v1beta1:ClusterRole:a3fa7d7c8-54b2-4d7d-8324-7752b64e7296-4-nginx-ingress:
id: dfd67625-96c0-11ea-98ae-005056956986
type: rbac.authorization.k8s.io/v1beta1:ClusterRole
rbac.authorization.k8s.io/v1beta1:ClusterRoleBinding:a3fa7d7c8-54b2-4d7d-8324-7752b64e7296-4-nginx-ingress:
id: dfd82cb2-96c0-11ea-98ae-005056956986
type: rbac.authorization.k8s.io/v1beta1:ClusterRoleBinding
rbac.authorization.k8s.io/v1beta1:Role:doc:example-nginx-ingress:
id: dfde6ee3-96c0-11ea-98ae-005056956986
type: rbac.authorization.k8s.io/v1beta1:Role
rbac.authorization.k8s.io/v1beta1:RoleBinding:doc:example-nginx-ingress:
id: dfe0b5a7-96c0-11ea-98ae-005056956986
type: rbac.authorization.k8s.io/v1beta1:RoleBinding
v1:Service:doc:example-nginx-ingress-controlle:
id: dfefa9fb-96c0-11ea-98ae-005056956986
type: v1:Service
v1:Service:doc:example-nginx-ingress-default-b:
id: dff52f4c-96c0-11ea-98ae-005056956986
type: v1:Service
v1:ServiceAccount:doc:example-nginx-ingress:
id: dfb4f7b8-96c0-11ea-98ae-005056956986
type: v1:ServiceAccount
v1:ServiceAccount:doc:example-nginx-ingress-backend:
id: dfb77967-96c0-11ea-98ae-005056956986
type: v1:ServiceAccount
```

Example with removed Helm release named `example`:
```
associatedTopology:
Helm:doc:example: null
apps/v1:Deployment:doc:example-nginx-ingress-controlle: null
apps/v1:Deployment:doc:example-nginx-ingress-default-b: null
rbac.authorization.k8s.io/v1beta1:ClusterRole:a3fa7d7c8-54b2-4d7d-8324-7752b64e7296-4-nginx-ingress: null
rbac.authorization.k8s.io/v1beta1:ClusterRoleBinding:a3fa7d7c8-54b2-4d7d-8324-7752b64e7296-4-nginx-ingress: null
rbac.authorization.k8s.io/v1beta1:Role:doc:example-nginx-ingress: null
rbac.authorization.k8s.io/v1beta1:RoleBinding:doc:example-nginx-ingress: null
v1:Service:doc:example-nginx-ingress-controlle: null
v1:Service:doc:example-nginx-ingress-default-b: null
v1:ServiceAccount:doc:example-nginx-ingress: null
v1:ServiceAccount:doc:example-nginx-ingress-backend: null
```
2 changes: 1 addition & 1 deletion docs/user-guide/building-a-resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ compose:
name: my-release-name
```

The value of `chart` must be either a file in the `helm` directory of your Resource’s Kubernetes directory or the name of a chart from a repository (that has been configured on the Helm server of your deployment location)
The value of `chart` must be either a file in the `helm` directory of your Resource’s Kubernetes directory or the name of a chart from a repository (that has been configured on the Helm server of your deployment location) e.g. `stable/nginx-ingress`.

A value must be set to give the release a name and you may optionally set the namespace to use (otherwise the default on the deployment location is used).

Expand Down
12 changes: 12 additions & 0 deletions docs/user-guide/ready-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ def checkReady(keg, props, resultBuilder, log, *args, **kwargs):

Each Helm release deployed is retrievable by it's name and namespace (Releases are actually different by their namespace but can have the same name in helm3).

As an example, if you've deployed a Helm chart in our kegd.yaml file:

```yaml
compose:
- name: Create
deploy:
- helm:
chart: nginx-ingress-1.24.4.tgz
name: MyReleaseName
namespace: MyNamespace
```

```python
def checkReady(keg, props, resultBuilder, log, *args, **kwargs):
found, helm_release = keg.helm_releases.get('MyReleaseName', 'MyNamespace')
Expand Down
60 changes: 59 additions & 1 deletion tests/unit/infrastructure/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,53 @@
from ignition.utils.propvaluemap import PropValueMap
from ignition.service.templating import Jinja2TemplatingService

multi_obj_template = '''
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ systemProperties.resourceSd }}
data:
dataValue: {{ propA }}
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ systemProperties.resourceSd }}
spec:
rules:
- host: {{ propB }}
http:
paths:
- path: /
backend:
serviceName: test
servicePort: 7777
'''

multi_obj_config_1 = '''
apiVersion: v1
kind: ConfigMap
metadata:
name: resource-a-123
data:
dataValue: A
'''
multi_obj_config_2 = '''
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: resource-a-123
spec:
rules:
- host: B
http:
paths:
- path: /
backend:
serviceName: test
servicePort: 7777
'''

class TestInfrastructureConverter(unittest.TestCase):

def setUp(self):
Expand All @@ -23,4 +70,15 @@ def __mock_properties(self):
system_properties['resourceId'] = {'type': 'string', 'value': '123'}
system_properties['resourceName'] = {'type': 'string', 'value': 'Resource-A'}
system_properties_map = PropValueMap(system_properties)
return system_properties_map, properties_map
return system_properties_map, properties_map

def test_convert_to_entity_group_with_objects(self):
system_properties, properties = self.__mock_properties()
entity_group = self.converter.convert_to_entity_group(multi_obj_template, TemplateTypes.OBJECT_CONFIG, system_properties, properties, self.kube_location)
self.assertEqual(entity_group.uid, 'resource-a-123')
self.assertEqual(len(entity_group.helm_releases), 0)
self.assertEqual(len(entity_group.objects), 2)
self.assertEqual(entity_group.objects[0].data, yaml.safe_load(multi_obj_config_1))
self.assertEqual(entity_group.objects[1].data, yaml.safe_load(multi_obj_config_2))


21 changes: 21 additions & 0 deletions tests/unit/kubeobjects/example_object_config_files/multidoc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: testing
data:
dataA: TestA
dataB: TestB
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: testing
spec:
rules:
- host: somehost
http:
paths:
- path: /
backend:
serviceName: test
servicePort: 7777
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: testing
data:
dataA: TestA
dataB: TestB
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: testing
spec:
rules:
- host: somehost
http:
paths:
- path: /
backend:
serviceName: test
servicePort: 7777
...
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: testing
data:
dataA: TestA
dataB: TestB
---
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: testing
spec:
rules:
- host: somehost
http:
paths:
- path: /
backend:
serviceName: test
servicePort: 7777
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: testing
data:
dataA: TestA
dataB: TestB
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: testing
spec:
rules:
- host: somehost
http:
paths:
- path: /
backend:
serviceName: test
servicePort: 7777
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: testing
data:
dataA: TestA
dataB: TestB
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: testing
spec:
rules:
- host: somehost
http:
paths:
- path: /
backend:
serviceName: test
servicePort: 7777
40 changes: 40 additions & 0 deletions tests/unit/kubeobjects/test_config_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,46 @@ def test_read_single_doc(self):
self.assertEqual(len(objects), 1)
self.assertEqual(objects[0].kind, 'ConfigMap')

def test_read_multi_doc(self):
file_content = load_example_file('multidoc')
docs = ObjectConfigurationDocument(file_content)
objects = docs.read()
self.assertEqual(len(objects), 2)
self.assertEqual(objects[0].kind, 'ConfigMap')
self.assertEqual(objects[1].kind, 'Ingress')

def test_read_multi_doc_with_doc_separator_at_start(self):
file_content = load_example_file('multidoc_separator_at_start')
docs = ObjectConfigurationDocument(file_content)
objects = docs.read()
self.assertEqual(len(objects), 2)
self.assertEqual(objects[0].kind, 'ConfigMap')
self.assertEqual(objects[1].kind, 'Ingress')

def test_read_multi_doc_with_doc_separator_at_end(self):
file_content = load_example_file('multidoc_separator_at_end')
docs = ObjectConfigurationDocument(file_content)
objects = docs.read()
self.assertEqual(len(objects), 2)
self.assertEqual(objects[0].kind, 'ConfigMap')
self.assertEqual(objects[1].kind, 'Ingress')

def test_read_multi_doc_with_dots_at_end(self):
file_content = load_example_file('multidoc_dots_at_end')
docs = ObjectConfigurationDocument(file_content)
objects = docs.read()
self.assertEqual(len(objects), 2)
self.assertEqual(objects[0].kind, 'ConfigMap')
self.assertEqual(objects[1].kind, 'Ingress')

def test_read_multi_doc_with_emptydoc_in_middle(self):
file_content = load_example_file('multidoc_emptydoc_in_middle')
docs = ObjectConfigurationDocument(file_content)
objects = docs.read()
self.assertEqual(len(objects), 2)
self.assertEqual(objects[0].kind, 'ConfigMap')
self.assertEqual(objects[1].kind, 'Ingress')

def test_read_invalid_yaml(self):
file_content = load_example_file('invalid_yaml')
docs = ObjectConfigurationDocument(file_content)
Expand Down

0 comments on commit 9c53123

Please sign in to comment.