Beispiel #1
0
 def __init__(self, name: str, props: NGINXProperties, opts=None):
     """Initializes NGINX using the given parameters."""
     super().__init__('glab:kubernetes:NGINX', name, None, opts)
     self.props = props
     self.namespace = Namespace('nginx-namespace',
                                metadata={"name": self.props.namespace_str},
                                opts=pulumi.ResourceOptions(parent=self))
     self.chart = Chart(
         'nginx-chart',
         ChartOpts(
             fetch_opts=FetchOpts(repo='https://helm.nginx.com/stable', ),
             chart='nginx-ingress',
             namespace=self.props.namespace_str,
             values={
                 'controller': {
                     'wildcardTLS': {
                         'secret':
                         '{}/{}'.format(self.props.namespace_str,
                                        'gilmanio-wildcard-cert-secret')
                     }
                 }
             }),
         opts=pulumi.ResourceOptions(parent=self,
                                     depends_on=[self.namespace]))
     self.widlcard_cert = CustomResource(
         'nginx-wildcard-cert',
         api_version='cert-manager.io/v1alpha2',
         kind='Certificate',
         metadata={
             'name': 'gilmanio-wildcard-cert',
             'namespace': self.props.namespace_str,
         },
         spec={
             'secretName': 'gilmanio-wildcard-cert-secret',
             'issuerRef': {
                 'name': 'letsencrypt',
                 'kind': 'ClusterIssuer'
             },
             'commonName': '*.gilman.io',
             'dnsNames': [
                 'gilman.io',
                 '*.gilman.io',
             ],
         },
         opts=pulumi.ResourceOptions(parent=self))
Beispiel #2
0
    def __init__(self, name: str, props: NFSProperties, opts=None):
        """Initializes NFSProvisioner using the given parameters."""
        super().__init__('glab:kubernetes:nfs', name, None, opts)
        self.props = props
        self.namespace = Namespace('nfs-namespace',
                                   metadata={"name": self.props.namespace_str},
                                   opts=pulumi.ResourceOptions(parent=self))

        self.chart = Chart('nfs-chart',
                           ChartOpts(repo='stable',
                                     chart='nfs-client-provisioner',
                                     namespace=self.props.namespace_str,
                                     values={
                                         'nfs': {
                                             'server': props.server,
                                             'path': props.path
                                         },
                                         "replicaCount": 3,
                                         "storageClass": {
                                             "name": "nfs"
                                         }
                                     }),
                           opts=pulumi.ResourceOptions(parent=self))
# That function requires passing values that are not be known until the resources are created.
# Thus, the use of "apply()" to wait for those values before calling the function.
creds = pulumi.Output.all(resource_group.name, k8s_cluster.name).apply(
    lambda args: containerservice.list_managed_cluster_user_credentials(
        resource_group_name=args[0], resource_name=args[1]))

# The "list_managed_cluster_user_credentials" function returns an array of base64 encoded kubeconfigs.
# So decode the kubeconfig for our cluster but mark it as a secret so Pulumi treats it accordingly.
kubeconfig = pulumi.Output.secret(creds.kubeconfigs[0].value.apply(
    lambda enc: base64.b64decode(enc).decode()))
### End of AKS Cluster Related Resources

# The K8s provider which supplies the helm chart resource needs to know how to talk to the K8s cluster.
# So, instantiate a K8s provider using the retrieved kubeconfig.
k8s_provider = k8s.Provider('k8s-provider', kubeconfig=kubeconfig)

# Create a chart resource to deploy apache using the k8s provider instantiated above.
apache = Chart('apache-chart',
               ChartOpts(
                   chart='apache',
                   version='8.3.2',
                   fetch_opts={'repo': 'https://charts.bitnami.com/bitnami'}),
               opts=ResourceOptions(provider=k8s_provider))

# Get the helm-deployed apache service IP which isn't known until the chart is deployed.
apache_service_ip = apache.get_resource(
    'v1/Service',
    'apache-chart').apply(lambda res: res.status.load_balancer.ingress[0].ip)

# Correct option using "concat()"
pulumi.export('Apache_URL', pulumi.Output.concat('http://', apache_service_ip))
Beispiel #4
0
traefik = Chart(
    "traefik",
    ChartOpts(
        chart="traefik",
        version="9.10.1",
        fetch_opts=FetchOpts(repo="https://helm.traefik.io/traefik"),
        namespace=traefik_namespace.metadata["name"],
        values={
            # Debugging
            # "logs": {"general": {"level": "DEBUG"}},
            # These are the ports that Traefik has open
            "ports": {
                # This one is used for readiness/liveness probes, and is not exposed
                "traefik": {
                    "port": 9000,
                    "expose": True,
                    "exposedPort": 9000,
                    "protocol": "TCP",
                },
                # This one is exposed on port 80, and is used for HTTP
                # It redirects traffic it receives to HTTPS
                "web": {
                    "port": 8000,
                    "expose": True,
                    "exposedPort": 80,
                    "protocol": "TCP",
                    "redirectTo": "websecure",
                },
                # This one is exposed on port 443, and is used for HTTPS
                "websecure": {
                    "port": 8443,
                    "expose": True,
                    "exposedPort": 443,
                    "protocol": "TCP",
                    "tls": {
                        "enabled": True,
                    }
                },
            },
        },
        transformations=[traefik_chart_transformation],
    ),
)
Beispiel #5
0
from pulumi_kubernetes.core.v1 import Namespace
from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts

cilium_namespace = Namespace("cilium")

cilium = Chart(
    "cilium",
    ChartOpts(
        chart="cilium",
        version="1.8.5",
        fetch_opts=FetchOpts(repo="https://helm.cilium.io"),
        namespace=cilium_namespace.metadata["name"],
        values={
            # The values change when upgrading cilium to 1.9, watch out!
            "operator": {
                "numReplicas": 1,
            },
        },
    ),
)
Beispiel #6
0
# Copyright 2016-2019, Pulumi Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pulumi_kubernetes.helm.v3 import Chart, LocalChartOpts

values = {"service": {"type": "ClusterIP"}}

Chart("nginx", LocalChartOpts(path="nginx", values=values))

# Deploy a duplicate chart with a different resource prefix to verify that multiple instances of the Chart
# can be managed in the same stack.
Chart("nginx",
      LocalChartOpts(path="nginx", resource_prefix="dup", values=values))
Beispiel #7
0
    resp = connection_pool.request('GET', local_path_provisioner_location)
    f.write(resp.data)
    f.close()

    resp.release_conn()

    with zipfile.ZipFile(download_location, 'r') as zip:
        zip.extractall(str(tmpdir))

    chart_location = tmpdir / f"local-path-provisioner-{local_path_provisioner_version}" / "deploy" / "chart"

    return str(chart_location)


local_path_provisioner = Chart(
    "local-path-provisioner",
    LocalChartOpts(
        path=download_lpp_chart(),
        namespace=local_path_provisioner_namespace.metadata["name"],
        values={
            "nodePathMap": [{
                "node": "DEFAULT_PATH_FOR_NON_LISTED_NODES",
                "paths": [local_path_storage],
            }],
            "storageClass": {
                "defaultClass": True,
            },
        },
    )
)
Beispiel #8
0
prometheus = Chart(
    "prometheus",
    ChartOpts(
        chart="prometheus",
        version="11.16.8",
        fetch_opts=FetchOpts(
            repo="https://prometheus-community.github.io/helm-charts"),
        namespace=prometheus_namespace.metadata["name"],
        values={
            "alertmanager": {
                "enabled": True,
                "ingress": {
                    "enabled": True,
                    "hosts": ["alertmanager.dev-k8s.ocf.berkeley.edu"],
                },
            },
            "server": {
                "ingress": {
                    "enabled": True,
                    "hosts": ["prometheus.dev-k8s.ocf.berkeley.edu"],
                }
            },
            # Conflicts w/ nodeExporter installed from Puppet.
            "nodeExporter": {
                "enabled": False,
            }
        },
    ),
)
Beispiel #9
0
rabbitmq = Chart(
    'rabbitmq-julioleal',
    config=ChartOpts(
        chart='rabbitmq',
        namespace=config_k8s.get("namespace"),
        fetch_opts=FetchOpts(repo="https://charts.bitnami.com/bitnami"),
        values={
            "replicaCount": data.get("replicaCount"),
            "resources": {
                "limits": {
                    "memory": data.get("resourcesLimitsMemory")
                },
            },
            "resources": {
                "limits": {
                    "cpu": data.get("resourcesLimitsCpu")
                },
            },
            "resources": {
                "requests": {
                    "memory": data.get("resourcesRequestsMemory"),
                },
            },
            "resources": {
                "requests": {
                    "cpu": data.get("resourcesRequestCpu"),
                },
            },
            "memoryHighWatermark": {
                "enabled": data.get("memoryHighWatermarkEnabled"),
            },
            "memoryHighWatermark": {
                "type": data.get("memoryHighWatermarkType"),
            },
            "memoryHighWatermark": {
                "value": data.get("memoryHighWatermarkValue"),
            },
            "extraPlugins": data.get("extraPlugins"),
            "auth": {
                "password": config.require_secret("rabbitmqAuthPassword"),
            },
            "auth": {
                "username": data.get("username"),
            },
            "service": {
                "type": data.get('serviceType'),
            },
            "clustering": {
                "forceBoot": data.get("forceBoot"),
            },
            "persistence": {
                "size": data.get("persistenceSize")
            },
        },
    ))
Beispiel #10
0
from pulumi_kubernetes.core.v1 import Namespace
from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts
from pulumi_random import RandomString

namespace = Namespace("test")

rs = RandomString("random-string", length=8).result

values = {"service": {"type": "ClusterIP"}, "random-string": rs}

Chart(
    "remote-chart",
    ChartOpts(
        chart="nginx",
        fetch_opts=FetchOpts(home=expanduser("~"),
                             repo="https://charts.bitnami.com/bitnami"),
        namespace=namespace.metadata["name"],
        values={"service": {
            "type": "ClusterIP"
        }},
        version="6.0.4",
    ))

# Deploy a duplicate chart with a different resource prefix to verify that multiple instances of the Chart
# can be managed in the same stack.
Chart(
    "remote-chart",
    ChartOpts(
        chart="nginx",
        resource_prefix="dup",
        fetch_opts=FetchOpts(home=expanduser("~"),
                             repo="https://charts.bitnami.com/bitnami"),
Beispiel #11
0
from pulumi_kubernetes.core.v1 import Namespace
from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts

vault_namespace = Namespace("vault")

cilium = Chart(
    "vault",
    ChartOpts(
        chart="vault",
        version="0.8.0",
        fetch_opts=FetchOpts(
            repo="https://helm.releases.hashicorp.com"),
        namespace=vault_namespace.metadata["name"],
        values={
            # Not yet configured...
            # https://github.com/hashicorp/vault-helm/blob/master/values.yaml
        },
    ),
)
Beispiel #12
0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pulumi_kubernetes.core.v1 import Namespace
from pulumi_kubernetes.helm.v3 import Chart, LocalChartOpts

namespace = Namespace("test")

Chart("skip-crd-rendering", LocalChartOpts(
    skip_crd_rendering=True,
    skip_await=False,
    namespace=namespace.metadata["name"],
    path="helm-skip-crd-rendering",
))

Chart("allow-crd-rendering", LocalChartOpts(
    skip_crd_rendering=False,
    skip_await=True,
    namespace=namespace.metadata["name"],
    path="helm-allow-crd-rendering",
))
Beispiel #13
0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pulumi_kubernetes.core.v1 import Namespace
from pulumi_kubernetes.helm.v3 import Chart, LocalChartOpts

namespace = Namespace("test")

Chart(
    "api-versions",
    LocalChartOpts(
        api_versions=["foo", "bar"],
        namespace=namespace.metadata["name"],
        path="helm-api-versions",
    ))

Chart(
    "single-api-version",
    LocalChartOpts(
        api_versions=["foo"],
        namespace=namespace.metadata["name"],
        path="helm-single-api-version",
    ))
Beispiel #14
0
"""A Kubernetes Python Pulumi program"""

import pulumi
from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts

mongodb = Chart(
    'mongodb-julioleal',
    config=ChartOpts(
        chart='mongodb',
        namespace="julioleal",
        fetch_opts=FetchOpts(repo="https://charts.bitnami.com/bitnami"),
        values={
            "auth": {
                "enabled": False,
            },
            "persistence": {
                "size": "20Gi",
            },
        },
    ))

# Export the public IP for WordPress.
#frontend = mongodb.get_resource('v1/Service', 'mongodb-julioleal')
#pulumi.export('frontend_ip', frontend.status.load_balancer.ingress[0].ip)