Exemplo n.º 1
0
        private async Task InjectClusterCacheConfigurationAsync(Cluster newCluster)
        {
            var values = new List <KeyValuePair <string, string> >();

            values.Add(new KeyValuePair <string, string>($"traefik/http/routers/{newCluster.Name}/rule", $"Host(`{newCluster.Name}.ice-artefact.com`)"));
            values.Add(new KeyValuePair <string, string>($"traefik.http.routers.{newCluster.Name}.entrypoints/0", $"web"));
            values.Add(new KeyValuePair <string, string>($"traefik.http.routers.{newCluster.Name}.entrypoints/1", $"webSecure"));
            values.Add(new KeyValuePair <string, string>($"traefik/http/routers/{newCluster.Name}/service", $"{newCluster.Name}-http-lb"));
            values.Add(new KeyValuePair <string, string>($"traefik/http/services/{newCluster.Name}-http-lb/loadbalancer/servers/0/url", $"http://{newCluster.Ip}:80"));
            values.Add(new KeyValuePair <string, string>($"traefik/http/services/{newCluster.Name}-http-lb/loadbalancer/servers/1/url", $"https://{newCluster.Ip}:443"));
            values.Add(new KeyValuePair <string, string>($"traefik/http/services/{newCluster.Name}-http-lb/loadbalancer/servers/2/url", $"https://{newCluster.Ip}:6443"));

            await traefikCache.StoreValues(values);
        }
        public async Task GenerateClusterBasicRules(Cluster cluster)
        {
            var traefikBasesRules = GenerateKubectlBaseRouting(cluster.Id, cluster.Domain, cluster.Name, cluster.Ip);

            traefikBasesRules.AddRange(GenerateHttpBaseRouting(cluster.Id, cluster.Domain, cluster.Name, cluster.Ip));
            traefikBasesRules.AddRange(GenerateHttpsBaseRouting(cluster.Id, cluster.Domain, cluster.Name, cluster.Ip));

            if ((await traefikRouteValueRepository.InsertsAsync(traefikBasesRules.ToArray()) == traefikBasesRules.Count))
            {
                var values = ConvertToKvp(traefikBasesRules.ToArray());
                await traefikRedisStore.StoreValues(values.ToList());
            }
        }
Exemplo n.º 3
0
        private async Task LinkDomainToClusterCacheAsync(string clusterName, string ip, string domain, string resolver)
        {
            var ruleName = domain.Replace(".", "-");

            var values = new List <KeyValuePair <string, string> >();

            values.Add(new KeyValuePair <string, string>($"traefik/http/services/{clusterName}-https-{ruleName}-lb/loadbalancer/servers/0/url", $"https://{ip}:443"));
            values.Add(new KeyValuePair <string, string>($"traefik/http/routers/{clusterName}-https-{ruleName}/entrypoints/0", $"websecure"));
            values.Add(new KeyValuePair <string, string>($"traefik/http/routers/{clusterName}-https-{ruleName}/tls", "true"));
            values.Add(new KeyValuePair <string, string>($"traefik/http/routers/{clusterName}-https-{ruleName}/service", $"{clusterName}-https-{ruleName}-lb"));
            values.Add(new KeyValuePair <string, string>($"traefik/http/routers/{clusterName}-https-{ruleName}/rule", $"Host(`{domain}`)"));
            values.Add(new KeyValuePair <string, string>($"traefik/http/routers/{clusterName}-https-{ruleName}/tls/domains/0/main", $"{domain}"));

            if (!string.IsNullOrEmpty(resolver))
            {
                values.Add(new KeyValuePair <string, string>($"traefik/http/routers/{clusterName}-https-{ruleName}/tls/certresolver", $"{resolver}"));
            }

            await traefikCache.StoreValues(values);
        }