Creating Services by Exposing Ports
Learn how to create Kubernetes Services by exposing ports.
We'll cover the following...
Creating ReplicaSets
Before we dive into Services, we should create a ReplicaSet similar to the one we used in the previous chapter. It’ll provide the Pods that we can use to demonstrate how Services work.
Let’s look at the ReplicaSet definition go-demo-2-rs
.
The only significant difference is the db
container definition:
Press + to interact
...- name: dbimage: mongo:3.3command: ["mongod"]args: ["--rest", "--httpinterface"]ports:- containerPort: 28017protocol: TCP...
We customize the command and the arguments so that MongoDB exposes the REST interface. We also define the containerPort
. Those additions are needed so that we can test that the database is accessible through the Service.
Let’s create the ReplicaSet:
...