public static PodMonitor CreatePodMonitor( AutoDevOpsSettings settings, Pulumi.Kubernetes.Apps.V1.Deployment deployment, Namespace kubeNamespace, ProviderResource?providerResource = null ) => new(
public static Ingress Create( Output <string> namespaceName, AutoDevOpsSettings settings, string ingressClass, Dictionary <string, string>?annotations = null, ProviderResource?providerResource = null ) { var ingressLabels = settings.BaseLabels(); var tlsEnabled = settings.Ingress.Tls?.Enabled == true; var ingressAnnotations = (annotations ?? new Dictionary <string, string>()) .AsInputMap() .AddPair("kubernetes.io/ingress.class", ingressClass) .AddPairIf(tlsEnabled, "kubernetes.io/tls-acme", "true") .AddPairIf( settings.Prometheus.Metrics && ingressClass.Contains("nginx"), "nginx.ingress.kubernetes.io/server-snippet", "location /metrics { deny all; }" ); var uri = new Uri(settings.Deploy.Url); var ingress = new IngressArgs { Metadata = CreateArgs.GetMeta(settings.FullName(), namespaceName, ingressAnnotations, ingressLabels), Spec = new IngressSpecArgs { Rules = CreateArgs.IngressRule(uri.Host, settings.FullName(), settings.Service.ExternalPort), Tls = tlsEnabled ? new[] {
public static Deployment Create( Output <string> namespaceName, AutoDevOpsSettings settings, int replicas, Secret?imagePullSecret = null, Secret?appSecret = null, IEnumerable <ContainerArgs>?sidecars = null, Action <ContainerArgs>?configureContainer = null, Action <PodSpecArgs>?configurePod = null, Action <DeploymentArgs>?configureDeployment = null, ProviderResource?providerResource = null ) { var appLabels = settings.AppLabels(); var gitLabAnnotations = settings.GitLabAnnotations(); var containers = CreateArgs.GetAppContainers( settings.Application, settings.Deploy, settings.GitLab, appSecret, sidecars, configureContainer ); var deployment = new DeploymentArgs { Metadata = CreateArgs.GetMeta(settings.FullName(), namespaceName, gitLabAnnotations, appLabels), Spec = new DeploymentSpecArgs { Selector = new LabelSelectorArgs { MatchLabels = appLabels }, Replicas = replicas, Template = CreateArgs.GetPodTemplate( namespaceName, containers, imagePullSecret, appLabels, gitLabAnnotations, 60, configurePod ) } }; configureDeployment?.Invoke(deployment); return(new Deployment( settings.PulumiName("deployment"), deployment, new CustomResourceOptions { Provider = providerResource } )); }
public static Service Create( Output <string> namespaceName, AutoDevOpsSettings settings, Pulumi.Kubernetes.Apps.V1.Deployment deployment, Dictionary <string, string>?annotations = null, Action <ServiceArgs>?configureService = null, ProviderResource?providerResource = null ) { var selector = deployment.Spec.Apply(x => x.Selector.MatchLabels); return(Create(namespaceName, settings, selector, annotations, configureService, providerResource)); }
/// <summary> /// Create the application secret from CI variables, which are prefixed with K8S_SECRET_ /// </summary> /// <param name="namespaceName">Namespace, where the secret should be created</param> /// <param name="settings">AutoDevOps settings</param> /// <param name="providerResource">Optional: customer Kubernetes provider</param> /// <returns></returns> public static Secret?CreateAppSecret( Output <string> namespaceName, AutoDevOpsSettings settings, ProviderResource?providerResource = null ) { var env = GetEnvironmentVariables(); var vars = new Dictionary <string, string>(); foreach (DictionaryEntry entry in env) { var key = (string)entry.Key; if (key.StartsWith("K8S_SECRET_") && entry.Value != null) { vars[key.Remove(0, 11)] = (string)entry.Value; } } if (settings.Env != null) { foreach (var(name, value) in settings.Env) { vars[name] = value; } } if (vars.Count == 0) { return(null); } var secretName = $"{settings.Application.Name}-secret"; return(new Secret( secretName, new SecretArgs { Metadata = CreateArgs.GetMeta(secretName, namespaceName), Type = "opaque", StringData = vars }, new CustomResourceOptions { Provider = providerResource } )); }
static Service Create( Output <string> namespaceName, AutoDevOpsSettings settings, InputMap <string> selector, Dictionary <string, string>?annotations = null, Action <ServiceArgs>?configureService = null, ProviderResource?providerResource = null ) { var serviceLabels = settings.BaseLabels(); var serviceAnnotations = (annotations ?? new Dictionary <string, string>()) .AsInputMap(); if (settings.Prometheus.Metrics && !settings.Prometheus.Operator) { serviceAnnotations .AddPair("prometheus.io/scrape", "true") .AddPair("prometheus.io/path", settings.Prometheus.Path) .AddPair("prometheus.io/port", settings.Service.ExternalPort.ToString()); } var serviceArgs = new ServiceArgs { Metadata = CreateArgs.GetMeta(settings.FullName(), namespaceName, serviceAnnotations, serviceLabels), Spec = new ServiceSpecArgs { Type = settings.Service.Type, Ports = new List <ServicePortArgs> { new() { Name = "web", Port = settings.Service.ExternalPort, TargetPort = settings.Application.Port, Protocol = "TCP" } },