|
| 1 | +# Quickstart |
| 2 | + |
| 3 | +To run this, make sure you have: |
| 4 | + |
| 5 | +* Access to a Kubernetes cluster running at least version `1.11.3` with support for [LoadBalancer](./concepts.md#supported-service-types) type of services and that can perform outbound HTTP/S requests successfully. |
| 6 | + * You can even try with [KinD](https://kind.sigs.k8s.io/) or [Minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/), but make sure *Load Balancer*s work. |
| 7 | +* [Kubectl 1.11.3+](https://kubernetes.io/docs/tasks/tools/install-kubectl/) |
| 8 | +* An AWS account |
| 9 | +* AWS Credentials file |
| 10 | + |
| 11 | +Finally, [kubeconfig](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) needs to be properly set up. |
| 12 | + |
| 13 | +## Let's go |
| 14 | + |
| 15 | +### 1 - Clone the project |
| 16 | + |
| 17 | +```bash |
| 18 | +git clone https://github.com/CloudNativeSDWAN/cnwan-operator.git |
| 19 | +cd ./cnwan-operator |
| 20 | +``` |
| 21 | + |
| 22 | +### 2 - Deploy a test service |
| 23 | + |
| 24 | +We will suppose you are deploying an application on your cluster where your employees can log in and watch training videos. |
| 25 | + |
| 26 | +Run this to deploy a new namespace and a service in that namespace: |
| 27 | + |
| 28 | +```bash |
| 29 | +cat <<EOF | kubectl create -f - |
| 30 | +kind: Namespace |
| 31 | +apiVersion: v1 |
| 32 | +metadata: |
| 33 | + name: training-app-namespace |
| 34 | + labels: |
| 35 | + purpose: "test" |
| 36 | + operator.cnwan.io/watch: "enabled" |
| 37 | +--- |
| 38 | +kind: Service |
| 39 | +apiVersion: v1 |
| 40 | +metadata: |
| 41 | + name: web-training |
| 42 | + namespace: training-app-namespace |
| 43 | + labels: |
| 44 | + app: "training" |
| 45 | + annotations: |
| 46 | + version: "2.1" |
| 47 | + traffic-profile: "standard" |
| 48 | +spec: |
| 49 | + ports: |
| 50 | + - name: port80 |
| 51 | + protocol: TCP |
| 52 | + port: 80 |
| 53 | + targetPort: 8080 |
| 54 | + selector: |
| 55 | + app: "training" |
| 56 | + type: LoadBalancer |
| 57 | +EOF |
| 58 | +``` |
| 59 | + |
| 60 | +Please notice that the namespace has this label: `operator.cnwan.io/watch: enabled` which instructs the operator to watch events occurring in this namespace. Also notice that the service has annotations that will be registered as [metadata](./concepts.md#metadata): |
| 61 | + |
| 62 | +```yaml |
| 63 | +annotations: |
| 64 | + traffic-profile: standard |
| 65 | +``` |
| 66 | +
|
| 67 | +Now verify that the namespace is there: |
| 68 | +
|
| 69 | +```bash |
| 70 | +kubectl get ns |
| 71 | + |
| 72 | +NAME STATUS AGE |
| 73 | +training-app-namespace Active 1h |
| 74 | +``` |
| 75 | + |
| 76 | +Verify that the service is there and has an IP: |
| 77 | + |
| 78 | +```bash |
| 79 | +kubectl get service -n training-app-namespace |
| 80 | + |
| 81 | +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
| 82 | +web-training LoadBalancer 10.11.12.13 20.21.22.23 80:32058/TCP 1h |
| 83 | +``` |
| 84 | + |
| 85 | +If you see `<none>` or `<pending>` under `EXTERNAL-IP` you either have to wait to see an IP there or your cluster doesn't support [LoadBalancer](./concepts.md#supported-service-types). |
| 86 | + |
| 87 | +It doesn't really matter that there is no pod backing this service for now, as this is just a test. Of course, in a real world scenario you should make sure a pod is there. |
| 88 | + |
| 89 | +### 3 - Provide the credentials file |
| 90 | + |
| 91 | +Navigate to the root directory and place your credentials file to `artifacts/secrets`, with name `credentials`. |
| 92 | + |
| 93 | +### 4 - Provide settings |
| 94 | + |
| 95 | +From the root directory navigate to `artifacts/settings` and modify the file `settings.yaml` to look like this - please provide appropriate values in place of `<gcloud-project>` and `<gcloud-region>`: |
| 96 | + |
| 97 | +```yaml |
| 98 | +watchNamespacesByDefault: false |
| 99 | +serviceAnnotations: |
| 100 | + - traffic-profile |
| 101 | + - version |
| 102 | +serviceRegistry: |
| 103 | + awsCloudMap: |
| 104 | + defaultRegion: <region> |
| 105 | +``` |
| 106 | +
|
| 107 | +Please notice the values inside `annotations`: |
| 108 | + |
| 109 | +```yaml |
| 110 | + annotations: |
| 111 | + - traffic-profile |
| 112 | + - version |
| 113 | +``` |
| 114 | + |
| 115 | +This means that the operator will register `traffic-profile` as tags if it finds it among a [service's annotations list](./concepts.md#allowed-annotations). |
| 116 | + |
| 117 | +### 5 - Deploy the operator |
| 118 | + |
| 119 | +From the root directory of the project, execute |
| 120 | + |
| 121 | +```bash |
| 122 | +./scripts/deploy.sh cloudmap |
| 123 | +``` |
| 124 | + |
| 125 | +### 6 - See it on Cloud Map |
| 126 | + |
| 127 | +Now, log in to Cloud Map from the AWS console and after some time you will see a namespace that has the same name as the Kubernetes namespace where that service was found in. |
| 128 | + |
| 129 | +If you click on it, you will see a service: its tags contain `traffic-profile: standard`. It will also contain an instance with data about the port and the address. |
| 130 | + |
| 131 | +### 7 - Update metadata |
| 132 | + |
| 133 | +Now you're basically done, but you can follow these additional steps to see more of the operator in action. |
| 134 | + |
| 135 | +Suppose you made a mistake: this is a training application where your employees will follow video tutorials and therefore, its kind of traffic - or, *profile*, must be `video`. |
| 136 | + |
| 137 | +Execute: |
| 138 | + |
| 139 | +```bash |
| 140 | +kubectl annotate service web-training traffic-profile=video --overwrite -n training-app-namespace |
| 141 | +``` |
| 142 | + |
| 143 | +The operator has updated the tags in Cloud Map accordingly. |
| 144 | + |
| 145 | +### 8 - Add new metadata |
| 146 | + |
| 147 | +Suppose you have a CI/CD pipeline that for each PR builds a container with a new tag. Also, it updates the service that serves the pods running that container by specifying the new version. Today, you will be that pipeline: |
| 148 | + |
| 149 | +```bash |
| 150 | +kubectl annotate service web-training version=2.2 -n training-app-namespace --overwrite |
| 151 | +``` |
| 152 | + |
| 153 | +Once again, log in to Cloud Map and see how the tags for that service have changed accordingly. |
| 154 | + |
| 155 | +## Where to go from here |
| 156 | + |
| 157 | +Well, that's it for a quickstart. Now we encourage you to learn more about CN-WAN Operator by taking a look at the [docs](./). |
| 158 | + |
| 159 | +Also, make sure you read the [official documentation of CN-WAN](https://github.com/CloudNativeSDWAN/cnwan-docs) to learn how you can apply this simple quickstart to a real world scenario. |
| 160 | + |
| 161 | +## Clean up |
| 162 | + |
| 163 | +From the root directory of the project, run |
| 164 | + |
| 165 | +```bash |
| 166 | +./scripts/remove.sh |
| 167 | +kubectl delete ns training-app-namespace |
| 168 | +``` |
0 commit comments