in src/Cli/func/Kubernetes/KubernetesHelper.cs [499:598]
private static DeploymentV1Apps GetDeployment(string name, string @namespace, string image, string pullSecret, int replicaCount, IDictionary<string, string> additionalEnv = null, IDictionary<string, string> annotations = null, int port = -1)
{
var deployment = new DeploymentV1Apps
{
ApiVersion = "apps/v1",
Kind = "Deployment",
Metadata = new ObjectMetadataV1
{
Namespace = @namespace,
Name = name,
Labels = new Dictionary<string, string>
{
{ "app", name }
},
Annotations = annotations
},
Spec = new DeploymentSpecV1Apps
{
Replicas = replicaCount,
Selector = new SelectorV1
{
MatchLabels = new Dictionary<string, string>
{
{ "app", name }
}
},
Template = new PodTemplateV1
{
Metadata = new ObjectMetadataV1
{
Labels = new Dictionary<string, string>
{
{ "app", name }
}
},
Spec = new PodTemplateSpecV1
{
Containers = new ContainerV1[]
{
new ContainerV1
{
Name = name,
Image = image,
Env = additionalEnv == null
? null
: additionalEnv.Select(kv => new ContainerEnvironmentV1 { Name = kv.Key, Value = kv.Value }),
Ports = port == -1
? null
: new ContainerPortV1[]
{
new ContainerPortV1
{
ContainerPort = 80
}
},
ReadinessProbe = new Probe
{
FailureThreshold = 3,
HttpGet = new HttpAction
{
Path = "/",
Port = 80,
Scheme = "HTTP"
},
PeriodSeconds = 10,
SuccessThreshold = 1,
TimeoutSeconds = 240
},
StartupProbe = new Probe
{
FailureThreshold = 3,
HttpGet = new HttpAction
{
Path = "/",
Port = 80,
Scheme = "HTTP"
},
PeriodSeconds = 10,
SuccessThreshold = 1,
TimeoutSeconds = 240
}
}
},
ImagePullSecrets = string.IsNullOrEmpty(pullSecret)
? null
: new ImagePullSecretV1[]
{
new ImagePullSecretV1
{
Name = pullSecret
}
}
}
}
}
};
return deployment;
}