You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a user, I wish to access my application deployed in a container/pod/Deployment using a URL.
How
Improve the kodo deploy command to create the following behind the scenes:
A corresponding Service( makes the app accessible from inside the cluster.. )
A corresponding Route to the Service ( makes the app accessible from the internet )
Hint
Creating a Service
This is a yaml representation of a Service:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: should-be-same-as-that-in-Deployment
ports:
- protocol: TCP
port: 80 # incoming traffic, will be directed to 'targetPort'
targetPort: 8081 # port the app is listening on, in the pod, obtain from `--port=`
You could create the same by doing the following:
// use the following imports
// "k8s.io/api/core/v1"
// "k8s.io/apimachinery/pkg/util/intstr"
// metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
svc := &v1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "unique-service-name",
},
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Port: 80, // use correct datatype, hint: int32
Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(int(port)), // port is to be obtained from the command flag.
},
},
Selector: map[string]string{
"app": "should-be-same-as-that-in-Deployment",
},
},
}
clientset.CoreV1().Services(NAMESPACE).Create(svc)
Creating a route
Here's how a yaml representation of a Route looks like
apiVersion: v1
kind: Route
metadata:
name: host-route
spec:
to:
kind: Service
name: service-name
Depends on #11
What
As a user, I wish to access my application deployed in a container/pod/Deployment using a URL.
How
Improve the
kodo deploy
command to create the following behind the scenes:Service
( makes the app accessible from inside the cluster.. )Route
to theService
( makes the app accessible from the internet )Hint
Creating a
Service
This is a yaml representation of a
Service
:You could create the same by doing the following:
Creating a route
Here's how a yaml representation of a
Route
looks likeHere's how to do the same using Golang APIs
Pull openshift client-go's master commit.
This needs kubernetes client-go to be at 0.18.3 #12
Create a route client
The text was updated successfully, but these errors were encountered: