apps = proto.package("k8s.io.api.apps.v1")
core = proto.package("k8s.io.api.core.v1")
meta = proto.package("k8s.io.apimachinery.pkg.apis.meta.v1")
def deployment(name, labels={}, replicas=1, containers=[]):
return apps.Deployment(
metadata = meta.ObjectMeta(name = name),
spec = apps.DeploymentSpec(
selector = meta.LabelSelector(matchLabels = labels),
replicas = replicas,
template = core.PodTemplateSpec(
metadata = meta.ObjectMeta(labels = labels),
spec = core.PodSpec(containers = containers),
),
)
)
def nginx(version, port=80):
return core.Container(
name = "nginx",
image = "nginx:{}".format(version),
ports = [core.ContainerPort(containerPort = port)],
)
def main(ctx):
return [deployment(
name = "nginx-deployment",
labels = {"app": "nginx"},
replicas = 2,
containers = [nginx("1.8")]
)]