Skip to content

Simple sleep service

The Simple sleep service is a minimal containerized service designed primarily as a request source for testing and experimenting with Service mesh features.^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__sleep__README.md]

Functionality

The service performs no active logic beyond idling.^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__sleep__README.md] It is implemented as an Ubuntu container with curl installed, allowing it to execute manual commands against other services.^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__sleep__README.md]

Usage

To utilize the service, it must be deployed into a Kubernetes cluster with Istio.

Deployment

  1. Istio Prerequisite: Ensure Istio is installed by following the official documentation.^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__sleep__README.md]
  2. Start the Service:
    • With Automatic sidecar injection enabled, apply the manifest directly^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__sleep__README.md]:
      [kubectl](<./kubectl.md>) apply -f sleep.yaml
      
    • Without automatic injection, use istioctl to manually inject the sidecar before applying^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__sleep__README.md]:
      [kubectl](<./kubectl.md>) apply -f <([istioctl](<./istioctl.md>) kube-inject -f sleep.yaml)
      

Testing Networking

Once deployed, users can kubectl exec into the sleep Pod to invoke other services.^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__sleep__README.md] For example, to test connectivity to a ratings service (such as the one provided in the [[Bookinfo]] sample), the following workflow is used^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__sleep__README.md]:

  1. Identify the Pod name:
    export SLEEP_POD=$([kubectl](<./kubectl.md>) get [Pod](<./pod.md>) -l app=sleep -o jsonpath={.items..metadata.name})
    
  2. Execute the request:
    [kubectl](<./kubectl.md>) exec -it $SLEEP_POD -c sleep -- curl http://ratings.default.svc.cluster.local:9080/ratings/1
    

The service can also be used to test egress traffic (accessing services outside of the mesh).^[400-devops__07-Monitoring-and-Observability__k8s-istio__samples__sleep__README.md]

Sources

  • 400-devops__07-Monitoring-and-Observability__k8s-istio__samples__sleep__README.md