Skip to content

service

service value in Kubedeploy allows you to define parametars for Service object that would be created.

In Kubernetes, a Service is a method for exposing a network application that is running as one or more Pods in your cluster.

A key aim of Services in Kubernetes is that you don't need to modify your existing application to use an unfamiliar service discovery mechanism. You can run code in Pods, whether this is a code designed for a cloud-native world, or an older app you've containerized. You use a Service to make that set of Pods available on the network so that clients can interact with it.

Note

By default service is enabled without any service ports defined. If service.ports is undefined Kubedeploy will generate a ports list based on the exposed main container ports using ports value.

Additional containers ports will not be included in this automatically generated list of service ports.

Info

To limit exposed ports via Service object, you can define custom service.ports list.

Available values for service in Kubedeploy:

service:
  type: ClusterIP # (1)
  enabled: true # (2)
  headless: false # (3)
  ports: [] # (4)
  1. Set Service type. See Service for available options.
  2. Enable Service provisioning for release.
  3. (Feature state: 1.1.0) Create a headless service. See reference

  4. (list) Define listening ports for Service. If unspecified, chart will automatically generate ports list based on main container exposed ports. Example values in ports list:

    Example

    service:
      ports:
        - port: 80 # (required) - port number as integer
          targetPort: http # (required) - name of the exposed container or additionalContainer port as string
          protocol: TCP # (required) Define service protocol. See [Supported protocols](https://kubernetes.io/docs/concepts/services-networking/service/#protocol-support)
          name: http # (required) - name of the Service port as string. This should match container's port name
    

Simple configuration exposing all the container ports:

Default setup

values.yaml
nameOverride: my-app
image:
  repository: nginx
  tag: latest

replicaCount: 3

ports:
  - containerPort: 80
    name: http
  - containerPort: 8080
    name: metrics
Deploy command
helm install webapp sysbee/kubedeploy -f values.yaml

Service is always enabled so there is no need to specifically define any values for it. With the above values, Kubedeploy creates service object named webapp-myapp that will be listening on same ports as containerPorts: 80 and 8080. Service object will load balance requests between three application replicas.

Disabling service object

If you don't wish to deploy Service object it only requires adding the

service:
  enabled: false
to the previous example

Building on the previous example, if we only want to expose http port via Service object and leave the metrics port available only when contacting each pod directly we can simply define custom ports in service values

Define custom service object

values.yaml
nameOverride: my-app
image:
  repository: nginx
  tag: latest

replicaCount: 3

ports:
  - containerPort: 80
    name: http
  - containerPort: 8080
    name: metrics

service:
  ports:
    - port: 80
      targetPort: http # (1)
      protocol: TCP
      name: http # (2)
  1. targetPort is the name given to the containerPorts exposed via ports values
  2. name is the port name in Service object, and it should match the targetPort name
Deploy command
helm install webapp sysbee/kubedeploy -f values.yaml

In this example Service object will only Load balance port 80 between application replicas.

See also: