Skip to content

Commit

Permalink
Fix running tests (#14)
Browse files Browse the repository at this point in the history
* Fix running tests. Refactor.
  • Loading branch information
aattuluri authored Sep 23, 2019
1 parent cda5f76 commit 19c52bc
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 323 deletions.
96 changes: 9 additions & 87 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,13 @@
# Contributing to Admiral

## Pre-requisite
1. We'll need at least 2 kubernetes clusters running istio to see the power of Admiral :).
2. The ingressgateway loadbalancer is accessible from each cluster
3. The admiral repository is cloned: ```git clone https://github.com/istio-ecosystem/admiral.git```
4. GoLand has been downloaded ([download it here](https://www.jetbrains.com/go/download/download-thanks.html?platform=mac))
## Setting up Admiral for development
1. Decide the cluster admiral will run on. This is will be referred to as the `local cluster`. The `local cluster` is where we will deploy the client.
Set the env variable `LOCAL_CLUSTER` to point to the local cluster's KUBECONFIG.
We welcome contributions :)

```export LOCAL_CLUSTER=<pwd>/[email protected]```
2. Our other cluster will be referred to as the`remote cluster`. The `remote cluster` is where we will deploy a remote service that gets accessed by the client running in the `local cluster`, using an admiral generated service name.
Set the env variable `REMOTE_CLUSTER` to point to the remote cluster KUBECONFIG.

```export REMOTE_CLUSTER=<pwd>/[email protected]```
## Submitting PRs
* Make sure to check existing issues and file an issue before starting to work on a feature/bug. This will help prevent duplication of work.

3. Set up namespaces needed for the `remote cluster` and `local cluster`:
```
export KUBECONFIG=$REMOTE_CLUSTER
kubectl apply -f install/admiral/admiral-sync-ns.yaml
export KUBECONFIG=$LOCAL_CLUSTER
kubectl apply -f install/admiral/admiral-sync-ns.yaml
```
`Note:` You can also override these namespaces when you start admiral
4. Provision a service account on `local cluster` and `remote cluster`. Admiral will use it to talk to the k8s api server between clusters.
```
export KUBECONFIG=$REMOTE_CLUSTER
kubectl apply -f install/admiral/remote-sa.yaml
export KUBECONFIG=$LOCAL_CLUSTER
kubectl apply -f install/admiral/remote-sa.yaml
```
5. Run the following shell scripts (this fetches service account's secret from a cluster and drops it into `admiral-secret-ns` namespace in local cluster):
```
sh test/scripts/cluster-secret.sh $LOCAL_CLUSTER $REMOTE_CLUSTER
sh test/scripts/cluster-secret.sh $LOCAL_CLUSTER $LOCAL_CLUSTER
```
6. Create dependencies and global traffic policies CRDs in local cluster and create global traffic policy in remote cluser
```
export KUBECONFIG=$LOCAL_CLUSTER
kubectl apply -f admiral/crd/dependency.yaml
kubectl apply -f admiral/crd/globalTraffic.yaml
export KUBECONFIG=$REMOTE_CLUSTER
kubectl apply -f admiral/crd/globalTraffic.yaml
```
7. Open the admiral project in GoLand
* navigate to the `Run` tab and click `Edit Configurations`
* in the field `Program arguments` add the following parameters:
```
--kube_config <path_to_kube_config_of_local_cluster>
```
* check run after build
* specify `-i` in go `Go tool arguments`
8. Run admiral/admiral/cmd/admiral/cmd/main.go to make sure admiral started successfully
9. Create namespace in both clusters
```
export KUBECONFIG=$REMOTE_CLUSTER
kubectl apply -f examples/mc-namespace.yaml
export KUBECONFIG=$LOCAL_CLUSTER
kubectl apply -f examples/mc-namespace.yaml
```
10. Update examples/serverv1.0.yaml with the correct role, policy id, and identity. Deploy serverv1 on remote cluster
```
export KUBECONFIG=$REMOTE_CLUSTER
kubectl apply -f examples/serverv1.0.yaml -n mc
```
11. Update examples/client.yaml with the correct role, policy id, and assetId. Deploy client on local cluster
```
export KUBECONFIG=$LOCAL_CLUSTER
kubectl apply -f examples/client.yaml -n mc
```
12. Create dependency record in the `local cluster`
```
export KUBECONFIG=$LOCAL_CLUSTER
kubectl apply -f examples/dependency_record.yaml
```
13. At this point, the client app can discover names for server by filtering Istio Service Entries with identity label.
Shell into client to verify call to server is successful
```
export KUBECONFIG=$LOCAL_CLUSTER
kubectl exec -ti <client_pod_name> -c client sh -n mc
curl -v stage.server.global/hello
```
## Setting up for local Development
* Use `Single Cluster` or `Multi-Cluster` sections [HERE](./README.MD) to set up the local test cluster.
* Run `admiral` from your IDE.
```
/admiral/cmd/admiral/main.go --kube_config <path_to_kube_config>
```
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ build-mac:
$(GOBUILD) -o $(BINARY_DARWIN) -v $(MAIN_PATH_ADMIRAL)

test:
$(GOTEST) ./...
$(GOTEST) -v `go list ./... | grep -v github.com/admiral/admiral/pkg/client`

clean:
$(GOCLEAN)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ kubectl apply -f ./out/yaml/demosinglecluster.yaml
```
#create the secret for admiral to monitor.
#Since this is for a single cluster demo the remote and local context are the same
./test/scripts/cluster-secret.sh $KUBECONFIG $KUBECONFIG admiral
./install/scripts/cluster-secret.sh $KUBECONFIG $KUBECONFIG admiral
```
```
#point hosts ending in global to be resolved by istio coredns
./test/scripts/redirect-dns.sh
./install/scripts/redirect-dns.sh
```
#### Setup Sample Apps

Expand Down
59 changes: 0 additions & 59 deletions examples/client.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions examples/dependency_record.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions examples/mc-namespace.yaml

This file was deleted.

40 changes: 0 additions & 40 deletions examples/serverv1.0.yaml

This file was deleted.

File renamed without changes.
File renamed without changes.
23 changes: 0 additions & 23 deletions test/data/depedency1.yaml

This file was deleted.

55 changes: 0 additions & 55 deletions test/data/globalTraffic-env.yaml

This file was deleted.

38 changes: 0 additions & 38 deletions test/data/globalTraffic1.yaml

This file was deleted.

0 comments on commit 19c52bc

Please sign in to comment.