Skip to content

Latest commit

 

History

History
66 lines (55 loc) · 1.28 KB

tutorial.md

File metadata and controls

66 lines (55 loc) · 1.28 KB

Tutorial

This example will show you how to use the CCM to create a service of type: LoadBalancer.

Load balancer example

When you create a service with type: LoadBalancer an OCI load balancer will be created.

The example below will create an NGINX deployment and expose it via a load balancer. Note that the service type is set to LoadBalancer.

---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
---
kind: Service
apiVersion: v1
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  type: LoadBalancer
  ports:
  - name: http
    port: 80
    targetPort: 80

Create it

$ kubectl create -f examples/nginx-demo-svc.yaml

Watch the service and await a public IP address. This will be the load balancer IP which you can use to connect to your service.

$ kubectl get svc --watch
NAME            CLUSTER-IP     EXTERNAL-IP      PORT(S)        AGE
nginx-service   10.96.97.137   129.213.12.174   80:30274/TCP   5m

You can now access your service via the provisioned load balancer

$ curl -i http://129.213.12.174