예제 #1
0
    def define_options(self) -> Optional[Any]:
        """
        Declare the options for the Loki Stack builder.

        :return: The supported options
        """
        return {
            'basename': OptionDef(required=True, default_value='loki', allowed_types=[str]),
            'namespace': OptionDef(required=True, default_value='loki', allowed_types=[str]),
            'config': {
                'prometheus_annotation': OptionDef(required=True, default_value=False, allowed_types=[bool]),
                'loki_config': OptionDef(allowed_types=[str, ConfigFile]),
                'service_port': OptionDef(required=True, default_value=3100, allowed_types=[int]),
                'authorization': {
                    'serviceaccount_use': OptionDef(allowed_types=[str]),
                },
            },
            'container': {
                'loki': OptionDef(required=True, default_value='grafana/loki:2.0.0', allowed_types=[str]),
            },
            'kubernetes': {
                'volumes': {
                    'data': OptionDef(required=True, format=OptionDefFormat.KDATA_VOLUME,
                                      allowed_types=[Mapping, *KDataHelper_Volume.allowed_kdata()]),
                },
                'resources': {
                    'statefulset': OptionDef(allowed_types=[Mapping]),
                }
            },
        }
예제 #2
0
    def define_options(self):
        """
        Declare the options for the Ingress NGINX builder.

        :return: The supported options
        """
        return {
            # 'basename': OptionDef(),
            # 'namespace': OptionDef(),
            'config': {
                'github_commit':
                OptionDef(required=True,
                          default_value='ingress-nginx-3.7.1',
                          allowed_types=[str]),
                'provider_override':
                OptionDef(allowed_types=[str]),
            },
        }
예제 #3
0
 def test_options_default_value(self):
     opt = OptionsBase(defined_options={
         'foo': {
             'bar': OptionDef(default_value='baz'),
         }
     }, options={
         'foo': {
         }
     })
     self.assertEqual(option_root_get(opt, 'foo.bar'), 'baz')
예제 #4
0
 def test_options_value_callable(self):
     opt = OptionsBase(defined_options={
         'foo': {
             'bar': OptionDef(default_value='baz'),
         }
     }, options={
         'foo': {
             'bar': OptionValueCallable(lambda n, o: 'baz_value'),
         }
     })
     self.assertEqual(option_root_get(opt, 'foo.bar'), 'baz_value')
예제 #5
0
 def test_options_helper(self):
     opt = OptionsBase(defined_options={
         'foo': {
             'bar': OptionDef(default_value='baz'),
         }
     }, options={
         'foo': {
             'bar': LiteralStr('baz_literal'),
         }
     })
     self.assertIsInstance(option_root_get(opt, 'foo.bar'), HelperStr)
예제 #6
0
 def test_options_required(self):
     with self.assertRaises(TypeError):
         opt = OptionsBase(defined_options={
             'foo': {
                 'bar': OptionDef(required=True),
             }
         }, options={
             'foo': {
             }
         })
         option_root_get(opt, 'foo.bar')
예제 #7
0
    def define_options(self) -> Optional[Any]:
        """
        Declare the options for the Loki config file.

        :return: The supported options
        """
        return {
            'config': {
                'merge_config': OptionDef(allowed_types=[Mapping]),
            },
        }
예제 #8
0
 def test_options_allowed_type(self):
     with self.assertRaises(TypeError):
         opt = OptionsBase(defined_options={
             'foo': {
                 'bar': OptionDef(required=True, allowed_types=[str, int]),
             }
         }, options={
             'foo': {
                 'bar': 3.0,
             }
         })
         option_root_get(opt, 'foo.bar')
예제 #9
0
 def test_options_defined(self):
     # Cannot create key when there are defined options
     with self.assertRaises(OptionError):
         OptionsBase(defined_options={
             'foo': {
                 'bar': OptionDef(default_value='baz'),
             }
         }, options={
             'foo': {
                 'nobar': 'nobaz',
             }
         })
예제 #10
0
 def test_options_data_disabled(self):
     opt = OptionsBase(defined_options={
         'foo': {
             'bar': OptionDef(default_value='baz'),
         }
     }, options={
         'foo': {
             'bar': ValueData('diz', enabled=False),
         }
     })
     self.assertIsNone(option_root_get(opt, 'foo.bar'))
     self.assertIsInstance(option_root_get(opt, 'foo.bar', handle_data=False), Data)
예제 #11
0
 def test_options_data_recursive(self):
     opt = OptionsBase(defined_options={
         'foo': {
             'bar': OptionDef(default_value='baz'),
         }
     }, options={
         'foo': {
             'bar': ValueData(ValueData('diz', enabled=True), enabled=True),
         }
     })
     self.assertEqual(option_root_get(opt, 'foo.bar'), 'diz')
     self.assertIsInstance(option_root_get(opt, 'foo.bar', handle_data=False), Data)
예제 #12
0
    def define_options(self) -> Optional[Any]:
        """
        Declare the options for the RabbitMQ config file.

        :return: The supported options
        """
        return {
            'enable': {
                'log_level':
                OptionDef(required=True,
                          default_value=True,
                          allowed_types=[bool]),
                'cluster_formation':
                OptionDef(required=True,
                          default_value=True,
                          allowed_types=[bool]),
            },
            'config': {
                'merge_config':
                OptionDef(default_value={}, allowed_types=[Mapping]),
            },
        }
예제 #13
0
 def test_options_data_inner2(self):
     opt = OptionsBase(defined_options={
         'foo': {
             'bar': OptionDef(default_value={}),
         }
     }, options={
         'foo': {
             'bar': {
                 'gin': ValueData(1, enabled=True),
                 'per': ValueData(2, enabled=False),
             },
         }
     })
     self.assertEqual(option_root_get(opt, 'foo.bar'), {'gin': 1})
예제 #14
0
 def test_options_data_inner(self):
     opt = OptionsBase(defined_options={
         'foo': {
             'bar': OptionDef(default_value=[]),
         }
     }, options={
         'foo': {
             'bar': [
                 ValueData(1, enabled=True),
                 ValueData(2, enabled=False),
             ],
         }
     })
     self.assertEqual(option_root_get(opt, 'foo.bar'), [1])
예제 #15
0
    def test_options_root(self):
        root_options = Options({
            'root_bar': 'baz',
        })

        opt = OptionsBase(defined_options={
            'foo': {
                'bar': OptionDef(required=True),
            }
        }, options={
            'foo': {
                'bar': OptionRoot('root_bar'),
            }
        })
        self.assertEqual(option_root_get(opt, 'foo.bar', root_options=root_options), 'baz')
예제 #16
0
    def test_options_value(self):
        class TOptionValue(OptionValue):
            def get_value(self, name: Optional[str] = None, base_option: Optional[Option] = None) -> Any:
                return 'baz_value'

        opt = OptionsBase(defined_options={
            'foo': {
                'bar': OptionDef(default_value='baz'),
            }
        }, options={
            'foo': {
                'bar': TOptionValue(),
            }
        })
        self.assertEqual(option_root_get(opt, 'foo.bar'), 'baz_value')
예제 #17
0
    def define_options(self) -> Optional[Any]:
        """
        Declare the options for the Prometheus config file.

        :return: The supported options
        """
        return {
            'config': {
                'merge_config':
                OptionDef(default_value={}, allowed_types=[Mapping]),
            },
            'scrape': {
                'prometheus': {
                    'enabled':
                    OptionDef(required=True,
                              default_value=False,
                              allowed_types=[bool]),
                    'job_name':
                    OptionDef(default_value='prometheus', allowed_types=[str]),
                    'merge_config':
                    OptionDef(default_value={}, allowed_types=[Mapping]),
                }
            },
        }
예제 #18
0
 def define_options(self):
     return {
         'basename':
         OptionDef(required=True, default_value='bt', allowed_types=[str]),
         'namespace':
         OptionDef(required=True, default_value='btns',
                   allowed_types=[str]),
         'config': {
             'service_port':
             OptionDef(required=True,
                       default_value=3000,
                       allowed_types=[int]),
             'frontend_url':
             OptionDef(allowed_types=[str]),
             'password':
             OptionDef(format=OptionDefFormat.KDATA_ENV,
                       allowed_types=[str, KData_Secret, KData_ConfigMap]),
             'config_file':
             OptionDef(required=True),
         },
         'container': {
             'bt': OptionDef(required=True, default_value='bt/bt:7.2.0'),
         },
         'kubernetes': {
             'volumes': {
                 'data':
                 OptionDef(required=True,
                           format=OptionDefFormat.KDATA_VOLUME,
                           default_value={'emptyDir': {}},
                           allowed_types=[
                               Mapping, *KDataHelper_Volume.allowed_kdata()
                           ]),
             },
             'resources': {
                 'deployment': OptionDef(),
             }
         },
     }
예제 #19
0
    def define_options(self) -> Optional[Any]:
        """
        Declare the options for the RabbitMQ builder.

        :return: The supported options
        """
        return {
            'basename':
            OptionDef(required=True,
                      default_value='rabbitmq',
                      allowed_types=[str]),
            'namespace':
            OptionDef(required=True,
                      default_value='rabbitmq',
                      allowed_types=[str]),
            'config': {
                'enabled_plugins':
                OptionDef(default_value=['rabbitmq_peer_discovery_k8s'],
                          allowed_types=[Sequence]),
                'rabbitmq_conf':
                OptionDef(allowed_types=[str, ConfigFile]),
                'erlang_cookie':
                OptionDef(required=True,
                          default_value=str(uuid.uuid4()),
                          format=OptionDefFormat.KDATA_VOLUME,
                          allowed_types=[str, dict, KData_Secret]),
                'loglevel':
                OptionDef(required=True,
                          default_value='info',
                          allowed_types=[str]),
                'enable_prometheus':
                OptionDef(required=True,
                          default_value=True,
                          allowed_types=[bool]),
                'prometheus_annotation':
                OptionDef(required=True,
                          default_value=False,
                          allowed_types=[bool]),
                'load_definitions':
                OptionDef(format=OptionDefFormat.KDATA_VOLUME,
                          allowed_types=[str, KData_Secret]),
                'authorization': {
                    'serviceaccount_create':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                    'serviceaccount_use':
                    OptionDef(allowed_types=[str]),
                    'roles_create':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                    'roles_bind':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                },
            },
            'container': {
                'busybox':
                OptionDef(required=True,
                          default_value='busybox:1.32.0',
                          allowed_types=[str]),
                'rabbitmq':
                OptionDef(required=True,
                          default_value='rabbitmq:3.8.9-alpine',
                          allowed_types=[str]),
            },
            'kubernetes': {
                'volumes': {
                    'data':
                    OptionDef(required=True,
                              format=OptionDefFormat.KDATA_VOLUME,
                              allowed_types=[
                                  dict, *KDataHelper_Volume.allowed_kdata()
                              ]),
                },
                'resources': {
                    'statefulset': OptionDef(allowed_types=[dict]),
                }
            },
        }
예제 #20
0
    def define_options(self) -> Optional[Any]:
        """
        Declare the options for the EFK builder.

        :return: The supported options
        """
        return {
            'basename': OptionDef(required=True, default_value='efk', allowed_types=[str]),
            'namespace': OptionDef(required=True, default_value='default', allowed_types=[str]),
            'config': {
                'probes': OptionDef(required=True, default_value=False, allowed_types=[bool]),
                'elasticsearch': {
                    'replicas': OptionDef(required=True, default_value=3, allowed_types=[int]),
                },
                'kibana': {
                    'service_port': OptionDef(required=True, default_value=80, allowed_types=[int]),
                },
                'authorization': {
                    'serviceaccount_create': OptionDef(required=True, default_value=True, allowed_types=[bool]),
                    'serviceaccount_use': OptionDef(allowed_types=[str]),
                    'roles_create': OptionDef(required=True, default_value=True, allowed_types=[bool]),
                    'roles_bind': OptionDef(required=True, default_value=True, allowed_types=[bool]),
                },
            },
            'enable': {
                'kibana': OptionDef(required=True, default_value=True, allowed_types=[bool]),
            },
            'container': {
                'elasticsearch': OptionDef(required=True, default_value='docker.elastic.co/elasticsearch/elasticsearch:7.9.3', allowed_types=[str]),
                'kibana': OptionDef(required=True, default_value='docker.elastic.co/kibana/kibana:7.9.3', allowed_types=[str]),
                'fluentd': OptionDef(required=True, default_value='fluent/fluentd-kubernetes-daemonset:v1.11.4-debian-elasticsearch7-1.0', allowed_types=[str]),
            },
            'kubernetes': {
                'volumes': {
                    'elasticsearch-data': OptionDef(required=True, format=OptionDefFormat.KDATA_VOLUME,
                                                    allowed_types=[Mapping, *KDataHelper_Volume.allowed_kdata()]),
                },
                'resources': {
                    'elasticsearch-statefulset': OptionDef(allowed_types=[Mapping]),
                    'kibana-deployment': OptionDef(allowed_types=[Mapping]),
                    'fluentd-daemonset': OptionDef(allowed_types=[Mapping]),
                }
            },
        }
예제 #21
0
    def define_options(self):
        """
        Declare the options for the Prometheus builder.

        :return: The supported options
        """
        return {
            'basename':
            OptionDef(required=True,
                      default_value='prometheus',
                      allowed_types=[str]),
            'namespace':
            OptionDef(required=True,
                      default_value='prometheus',
                      allowed_types=[str]),
            'config': {
                'prometheus_config':
                OptionDef(required=True, allowed_types=[str, ConfigFile]),
                'service_port':
                OptionDef(required=True,
                          default_value=9090,
                          allowed_types=[int]),
                'authorization': {
                    'serviceaccount_create':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                    'serviceaccount_use':
                    OptionDef(allowed_types=[str]),
                    'roles_create':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                    'roles_bind':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                },
            },
            'container': {
                'init-chown-data':
                OptionDef(required=True,
                          default_value='debian:9',
                          allowed_types=[str]),
                'prometheus':
                OptionDef(required=True,
                          default_value='prom/prometheus:v2.21.0',
                          allowed_types=[str]),
            },
            'kubernetes': {
                'volumes': {
                    'data':
                    OptionDef(required=True,
                              format=OptionDefFormat.KDATA_VOLUME,
                              allowed_types=[
                                  Mapping, *KDataHelper_Volume.allowed_kdata()
                              ]),
                },
                'resources': {
                    'statefulset': OptionDef(allowed_types=[Mapping]),
                }
            },
        }
예제 #22
0
    def define_options(self):
        """
        Declare the options for the Kube Rsource Report builder.

        :return: The supported options
        """
        return {
            'basename':
            OptionDef(required=True,
                      default_value='kube-resource-report',
                      allowed_types=[str]),
            'namespace':
            OptionDef(required=True,
                      default_value='monitoring',
                      allowed_types=[str]),
            'config': {
                'service_port':
                OptionDef(required=True, default_value=80,
                          allowed_types=[int]),
                'authorization': {
                    'serviceaccount_create':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                    'serviceaccount_use':
                    OptionDef(allowed_types=[str]),
                    'roles_create':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                    'roles_bind':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                },
            },
            'container': {
                'kube-resource-report':
                OptionDef(required=True,
                          default_value='hjacobs/kube-resource-report:20.10.0',
                          allowed_types=[str]),
                'nginx':
                OptionDef(required=True,
                          default_value='nginx:1.19.4-alpine',
                          allowed_types=[str]),
            },
            'kubernetes': {
                'resources': {
                    'deployment': OptionDef(allowed_types=[Mapping]),
                    'deployment-nginx': OptionDef(allowed_types=[Mapping]),
                }
            },
        }
예제 #23
0
    def define_options(self):
        """
        Declare the options for the RabbitMQ Online builder.

        :return: The supported options
        """
        return {
            'basename':
            OptionDef(required=True,
                      default_value='rabbitmq',
                      allowed_types=[str]),
            'namespace':
            OptionDef(required=True,
                      default_value='rabbitmq',
                      allowed_types=[str]),
            'config': {
                'github':
                OptionDef(required=True,
                          default_value='rabbitmq/diy-kubernetes-examples',
                          allowed_types=[str]),
                'github_commit':
                OptionDef(required=True,
                          default_value='master',
                          allowed_types=[str]),
                'enabled_plugins':
                OptionDef(default_value=['rabbitmq_peer_discovery_k8s'],
                          allowed_types=[Sequence]),
                'rabbitmq_conf':
                OptionDef(allowed_types=[str, ConfigFile]),
                'admin': {
                    'username':
                    OptionDef(
                        required=True,
                        default_value='admin',
                        format=OptionDefFormat.KDATA_ENV,
                        allowed_types=[str, *KDataHelper_Env.allowed_kdata()]),
                    'password':
                    OptionDef(required=True,
                              format=OptionDefFormat.KDATA_ENV,
                              allowed_types=[str, KData_Secret]),
                },
                'erlang_cookie':
                OptionDef(required=True,
                          default_value=str(uuid.uuid4()),
                          format=OptionDefFormat.KDATA_VOLUME,
                          allowed_types=[str, KData_Secret]),
                'loglevel':
                OptionDef(required=True,
                          default_value='info',
                          allowed_types=[str]),
                'enable_prometheus':
                OptionDef(required=True,
                          default_value=True,
                          allowed_types=[bool]),
                'prometheus_annotation':
                OptionDef(required=True,
                          default_value=False,
                          allowed_types=[bool]),
                'load_definitions':
                OptionDef(format=OptionDefFormat.KDATA_VOLUME,
                          allowed_types=[str, KData_Secret]),
                'servicetype':
                OptionDef(required=True,
                          default_value='LoadBalancer',
                          allowed_types=[str]),
                'authorization': {
                    'serviceaccount_create':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                    'serviceaccount_use':
                    OptionDef(allowed_types=[str]),
                    'roles_create':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                    'roles_bind':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                },
            },
            'container': {
                'busybox': OptionDef(allowed_types=[str]),
                'rabbitmq': OptionDef(allowed_types=[str]),
            },
            'kubernetes': {
                'volumes': {
                    'data':
                    OptionDef(required=True,
                              format=OptionDefFormat.KDATA_VOLUME,
                              allowed_types=[
                                  Mapping,
                                  KDataHelper_Volume.allowed_kdata()
                              ]),
                },
                'resources': {
                    'statefulset': OptionDef(allowed_types=[Mapping]),
                }
            },
        }
예제 #24
0
    def define_options(self) -> Optional[Any]:
        """
        Declare the options for the Promtail builder.

        :return: The supported options
        """
        return {
            'basename':
            OptionDef(required=True,
                      default_value='promtail',
                      allowed_types=[str]),
            'namespace':
            OptionDef(required=True,
                      default_value='monitoring',
                      allowed_types=[str]),
            'config': {
                'prometheus_annotation':
                OptionDef(required=True,
                          default_value=False,
                          allowed_types=[bool]),
                'promtail_config':
                OptionDef(allowed_types=[str, ConfigFile]),
                'loki_url':
                OptionDef(allowed_types=[str]),
                'authorization': {
                    'serviceaccount_create':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                    'serviceaccount_use':
                    OptionDef(allowed_types=[str]),
                    'roles_create':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                    'roles_bind':
                    OptionDef(required=True,
                              default_value=True,
                              allowed_types=[bool]),
                },
            },
            'container': {
                'promtail':
                OptionDef(required=True,
                          default_value='grafana/promtail:2.0.0',
                          allowed_types=[str]),
            },
            'kubernetes': {
                'resources': {
                    'daemonset': OptionDef(allowed_types=[Mapping]),
                }
            },
        }