Creating Services by Exposing Ports
In this lesson, we will explore how to create Kubernetes Services by exposing ports.
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 we can use to demonstrate how Services work.
Let’s take a quick look at the ReplicaSet definition.
Press + to interact
cat svc/go-demo-2-rs.yml
The only significant difference is the db
container definition. It is as follows.
Press + to interact
...- name: dbimage: mongo:3.3command: ["mongod"]args: ["--rest", "--httpinterface"]ports:- containerPort: 28017protocol: TCP...
We customized the command and the arguments so that MongoDB exposes the REST interface. We also defined the containerPort
. Those additions are needed so that we can test that the database is accessible through the Service.
Let’s ...
Access this course and 1400+ top-rated courses and projects.