github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/caas/kubernetes/provider/config.go (about)

     1  // Copyright 2017 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package provider
     5  
     6  import (
     7  	"github.com/juju/schema"
     8  	"gopkg.in/juju/environschema.v1"
     9  	core "k8s.io/api/core/v1"
    10  )
    11  
    12  const (
    13  	defaultServiceType           = string(core.ServiceTypeClusterIP)
    14  	defaultIngressClass          = "nginx"
    15  	defaultIngressSSLRedirect    = false
    16  	defaultIngressSSLPassthrough = false
    17  	defaultIngressAllowHTTPKey   = false
    18  
    19  	serviceTypeConfigKey               = "kubernetes-service-type"
    20  	serviceExternalIPsConfigKey        = "kubernetes-service-external-ips"
    21  	serviceTargetPortConfigKey         = "kubernetes-service-target-port"
    22  	serviceLoadBalancerIPKey           = "kubernetes-service-loadbalancer-ip"
    23  	serviceLoadBalancerSourceRangesKey = "kubernetes-service-loadbalancer-sourceranges"
    24  	serviceExternalNameKey             = "kubernetes-service-externalname"
    25  	serviceAnnotationsKey              = "kubernetes-service-annotations"
    26  
    27  	ingressClassKey          = "kubernetes-ingress-class"
    28  	ingressSSLRedirectKey    = "kubernetes-ingress-ssl-redirect"
    29  	ingressSSLPassthroughKey = "kubernetes-ingress-ssl-passthrough"
    30  	ingressAllowHTTPKey      = "kubernetes-ingress-allow-http"
    31  )
    32  
    33  var configFields = environschema.Fields{
    34  	serviceTypeConfigKey: {
    35  		Description: "determines how the Service is exposed",
    36  		Type:        environschema.Tstring,
    37  		Group:       environschema.ProviderGroup,
    38  	},
    39  	serviceAnnotationsKey: {
    40  		Description: "a space separated set of annotations to add to the service",
    41  		Type:        environschema.Tattrs,
    42  		Group:       environschema.ProviderGroup,
    43  	},
    44  	serviceExternalIPsConfigKey: {
    45  		Description: "list of IP addresses for which nodes in the cluster will also accept traffic",
    46  		Type:        environschema.Tstring,
    47  		Group:       environschema.ProviderGroup,
    48  	},
    49  	serviceTargetPortConfigKey: {
    50  		Description: "name or number of the port to access on the pods targeted by the service",
    51  		Type:        environschema.Tstring,
    52  		Group:       environschema.ProviderGroup,
    53  	},
    54  	serviceLoadBalancerIPKey: {
    55  		Description: "LoadBalancer will get created with the IP specified in this field",
    56  		Type:        environschema.Tstring,
    57  		Group:       environschema.ProviderGroup,
    58  	},
    59  	serviceLoadBalancerSourceRangesKey: {
    60  		Description: "traffic through the load-balancer will be restricted to the specified client IPs",
    61  		Type:        environschema.Tstring,
    62  		Group:       environschema.ProviderGroup,
    63  	},
    64  	serviceExternalNameKey: {
    65  		Description: "external reference that kubedns or equivalent will return as a CNAME record",
    66  		Type:        environschema.Tstring,
    67  		Group:       environschema.ProviderGroup,
    68  	},
    69  	ingressClassKey: {
    70  		Description: "the class of the ingress controller to be used by the ingress resource",
    71  		Type:        environschema.Tstring,
    72  		Group:       environschema.ProviderGroup,
    73  	},
    74  	ingressSSLRedirectKey: {
    75  		Description: "whether to redirect SSL traffic to the ingress controller",
    76  		Type:        environschema.Tbool,
    77  		Group:       environschema.ProviderGroup,
    78  	},
    79  	ingressSSLPassthroughKey: {
    80  		Description: "whether to passthrough SSL traffic to the ingress controller",
    81  		Type:        environschema.Tbool,
    82  		Group:       environschema.ProviderGroup,
    83  	},
    84  	ingressAllowHTTPKey: {
    85  		Description: "whether to allow HTTP traffic to the ingress controller",
    86  		Type:        environschema.Tbool,
    87  		Group:       environschema.ProviderGroup,
    88  	},
    89  }
    90  
    91  var schemaDefaults = schema.Defaults{
    92  	serviceTypeConfigKey:     defaultServiceType,
    93  	serviceAnnotationsKey:    schema.Omit,
    94  	ingressClassKey:          defaultIngressClass,
    95  	ingressSSLRedirectKey:    defaultIngressSSLRedirect,
    96  	ingressSSLPassthroughKey: defaultIngressSSLPassthrough,
    97  	ingressAllowHTTPKey:      defaultIngressAllowHTTPKey,
    98  }
    99  
   100  // ConfigSchema returns the configuration schema for
   101  // a kubernetes provider config.
   102  func ConfigSchema() environschema.Fields {
   103  	return configFields
   104  }
   105  
   106  // ConfigDefaults returns the default values for
   107  // a kubernetes configuration.
   108  func ConfigDefaults() schema.Defaults {
   109  	return schemaDefaults
   110  }