Step 1: Deploy the AWS EKS cluster
To create an AWS EKS cluster, we will use eksctl tool. To create the EKS resources, create a
cluster.yaml file with the below configuration.
- name: node-group-1-spot-instances
instanceTypes: ["t3.small", "t3.medium"]
- name: vpc-cni
- name: coredns
- name: aws-ebs-csi-driver
- name: kube-proxy
This file defines the configuration for creating an AWS EKS cluster named
k8s-external-services in the
The configuration file also includes
- A managed node group called
node-group-1-spot-instances consisting of spot instances is a cost-effective option for running your workloads.
- The node group uses a mix of
t3.medium instance types, with a desired capacity of two nodes and a volume size of 8 GB for each node.
- The addons section lists the necessary components for the cluster, such as the
VPC CNI plugin,
CoreDNS for service discovery, the
AWS EBS CSI driver for dynamic provisioning of EBS volumes, and
Kube-proxy for managing network traffic between pods and services.
To apply the configuration, execute the command:
> eksctl create cluster -f cluster.yaml
This will create an EKS cluster with a node group of three nodes in the us-east-1 region. Once the cluster is ready, you should see an output similar to the one below.
EKS cluster "k8s-external-services" in "us-east-1" region is ready.
Next, we must update the kubeconfig file with newly created cluster access to interact with the cluster. To update the
kubeconfig, execute the command.
> aws eks --region us-east-1 update-kubeconfig --name k8s-external-services
To confirm the cluster access, run the command to get the Pods from the default namespace.
> kubectl get pods
Step 2: Create the Kubernetes external service
Next, let's create an External Service pointing to httpbin.org, a simple HTTP request/response service. It's a valuable tool for testing and debugging as it can simulate various HTTP responses.
Here's an example YAML configuration file for the external service:
Here's an explanation of the above yaml manifest:
apiVersion: v1 indicates the API version we use to create this object. In this case, v1 is the version of the core Kubernetes API.
kind: Service: This specifies the kind of Kubernetes object we're creating, which is a service in this case.
metadata: This section provides metadata about the object we're creating. It includes
name: httpbin-service: This is the name of our service. It's unique within a namespace.
namespace: default: This is the namespace where our service will be deployed. If not specified, the "default" namespace is used.
spec: This is where we define the specific characteristics of our object. For a service, we define the type of service and the external name. It includes
type: ExternalName: This specifies the type of service. An ExternalName service is unique because it doesn't have selectors and doesn't define any ports or endpoints. Instead, it serves as an alias for an external service.
externalName: httpbin.org: This is where we define the fully qualified domain name (FQDN) to which this service will map. Any traffic that tries to reach
httpbin-service will be directed to
You can apply this configuration using the kubectl command-line tool:
kubectl apply -f httpbin-service.yaml
Step 3: Deploy the Netshoot container
Now, let's deploy a sample application using Netshoot. Netshoot is a Docker and Kubernetes network troubleshooting tool packed with handy networking tools.