Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2b87739
add integration test - test cluster creation
janakiramanmesh7 Jan 3, 2023
d1f8594
run only one workflow
janakiramanmesh7 Jan 3, 2023
ebb5ea3
use usr/local/bin
janakiramanmesh7 Jan 3, 2023
424adcf
fix integration test checkout
janakiramanmesh7 Jan 3, 2023
e8261b1
draft
janakiramanmesh7 Jan 3, 2023
3344ab0
fix integration test go mod name
janakiramanmesh7 Jan 3, 2023
13711ae
test integration-test
janakiramanmesh7 Jan 3, 2023
753d8de
remove integration-test as gitmodule
janakiramanmesh7 Jan 3, 2023
2f41c96
add integration-tests
janakiramanmesh7 Jan 3, 2023
89ad5c1
removed docs folder
janakiramanmesh7 Jan 3, 2023
34f46aa
add docs as folder
janakiramanmesh7 Jan 3, 2023
9258646
start integration test after exporting GOPATH
janakiramanmesh7 Jan 3, 2023
07f7a87
check default core and memory
janakiramanmesh7 Jan 3, 2023
3706e13
test aws with github integration
janakiramanmesh7 Jan 4, 2023
0cdae50
add s3 ls to test access
janakiramanmesh7 Jan 4, 2023
5f8b76f
run on large runners
janakiramanmesh7 Jan 9, 2023
c6979c8
Merge branch 'main' into integration-test
janakiramanmesh7 Jan 9, 2023
34a8ea7
use main branch
janakiramanmesh7 Jan 9, 2023
3c0d121
use latest 4 core
janakiramanmesh7 Jan 9, 2023
20d606d
default runner group
janakiramanmesh7 Jan 9, 2023
da1bfe3
use label to fetch
janakiramanmesh7 Jan 10, 2023
5109bd4
use group name'
janakiramanmesh7 Jan 10, 2023
9ce9c01
use latest-4 core
janakiramanmesh7 Jan 10, 2023
ff66968
use ubuntu latest 4 core group
janakiramanmesh7 Jan 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/aws_access.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: AWS example workflow
on:
push
# permission can be added at job level or workflow level
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
S3PackageUpload:
runs-on:
group: ubuntu-latest-4-cores
steps:
- name: Git clone the repository
uses: actions/checkout@v3
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::284299419820:role/githubaccess
role-session-name: samplerolesession
aws-region: us-west-2
# Upload a file to AWS s3
- name: Copy index.html to s3
run: |
aws sts get-caller-identity
aws s3 ls
43 changes: 43 additions & 0 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Run integration test
on:
pull_request:
branches: [ main ]
jobs:
integration-test:
name: Build
runs-on:
labels: ubuntu-latest-4-cores
steps:
- name: Checkout github repository
uses: actions/checkout@v2
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: '>=1.17.0'
- name: setup-docker
uses: docker-practice/actions-setup-docker@1.0.11
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v0'
- name: Create Kind k8s cluster
uses: helm/kind-action@v1.4.0
with:
cluster_name: nexus
wait: 120s
node_image: gcr.io/nsx-sm/nexus/kind/node:v1.23.0
- name: Install kubectl
uses: azure/setup-kubectl@v3
with:
version: v1.23.0
- name: Create kind cluster and run integration test
run: |
set -x
kubectl wait pods -lcomponent=kube-apiserver -n kube-system --for=condition=ready --timeout=240s || { echo "k8s-apiserver pod could not be started" && exit 1; }
kubectl wait pods -lcomponent=kube-controller-manager -n kube-system --for=condition=ready --timeout=240s || { echo "k8s-controller-manager pod could not be started" && exit 1; }
curl -fsSL https://raw.githubusercontent.com/vmware-tanzu/graph-framework-for-microservices/main/cli/get-nexus-cli.sh -o get-nexus-cli.sh
bash get-nexus-cli.sh -d /usr/local/bin
nexus version
lscpu
free -mh
export GOPATH=$(go env GOPATH)
echo $GOPATH
cd integration-tests && ls && go run . workflows.yaml
Binary file added docs/.content/images/ApplicationWorkflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/DatamodelExample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/DeclarativeAPIWorkflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/NexusAdminRuntime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/NexusCLI.pm
Binary file not shown.
Binary file added docs/.content/images/NexusCLI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/NexusCompiler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/NexusConnector1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/NexusConnector2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/NexusRestAPISwaggerUI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/NexusRuntime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/NexusRuntimeAPIGW.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/NexusTenantRuntime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/OktaOIDCAppRedirectURLs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/RbacFlow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/RoleIllustration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/Scope.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/ShimLayerUsecase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/VerifyCustomAPI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/WhyNexus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/customapi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/nexus-oidc-sequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/nexus-rbac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.content/images/runtime-rbac-flow.png
24 changes: 24 additions & 0 deletions docs/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
image:
name: harbor-repo.vmware.com/nexus/runner:latest

include:
- project: "nsx-allspark_users/nexus-sdk/integration-tests"
file: ".gitlab-ci-template.yml"

before_script:
- git config --global url."https://gitlab.eng.vmware.com/".insteadOf "git@gitlab.eng.vmware.com:"
- git config --global gc.auto 0
- git config --global credential.helper store
- echo -e "https://gitlab-ci-token:${CICD_TOKEN}@gitlab.eng.vmware.com/" >> ~/.git-credentials

integration_test:
stage: integration_test
variables:
DOCS_VERSION: $CI_COMMIT_SHA
only:
- merge_requests
- master
extends: .run_integration_test

stages:
- integration_test
1 change: 1 addition & 0 deletions docs/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @rjanakiraman @sankarm @amallela @dbakiaraj
52 changes: 52 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Thank you for investing your time in contributing to Nexus SDK ✨.

# Contributor Guide

## Merge Requests / Pull Requests

### Commit Messages

Commit messages on the Merge Request should be of the format:

> **NPT-ABCD <[Summary](CONTRIBUTING.md#summary)>**
>
> **< blank line >**
>
> **[Problem statement](CONTRIBUTING.md#problem-statement) - can be description of bug, reason for change,
> need, ask etc.**
>
> **< blank line >**
>
> **[Description of fix](CONTRIBUTING.md#description-of-fix) / code change.**




#### Summary

* A properly formed git commit subject line should always be able to complete the following sentence
If applied, this commit will <your subject line here>
* Should state with Jira ID. Jira ID whould always be capitalized.
* Do not end the subject line with a period
* Use the imperative mood in the subject line
#### Problem statement
* Separate problem statement from subject, with a blank line
* Describe why a change is being made.
* Bullet points are okay.
* Do not assume the reviewer understands what the original problem was.
#### Description of fix
* Separate explanation from problem statement, with a blank line
* Bullet points are okay, too.
* Leave out details about how a change has been made, unless it is necessary for clarity.

An example / simple commit message, based on above quidelines.

```
NPT-239 Add a FAQ page to document important / frequent questions

In our documentation, there needs to be a place for info that come
up a questions frequently. The workflow page is sometime too verbose
to answer such questions quickly.

Add a FAQ page to the docs, where such questions can be captured.
```
56 changes: 56 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Nexus SDK

Nexus SDK is a platform, framework and runtime that provides an extensible, distributed stack that:
* accelerates cloud native application development
* simplifies consumption
* provides a out-of-the-box platform that is distributed, consistent, stable and feature rich
* provides a plug-and-play runtime for core platform functions

### [Get Started](getting_started/README.md)

## What are we trying to solve ?

The need for an unified SDK for quickly and easily building and provisioning a platform built for today's Cloud Native applications and products.

A [plethora of tools](https://collabnix.github.io/kubetools/), utilities and framwork have cropped up around kubernetes that aim to abstract and simplify different aspects of K8s.

What our products (and many products) need are contracts, not tools.
A unified framework that provides:

* API declaration, API endpoint management, versioning, packaging, rollout and more
* a hierarchical datamodel that is declarative, consistent, custom built and configurable
* API first design, with support for APIs beyond CRD's: graphql, custom REST API/URL etc
* an integrated RBAC that can be versioned, codified
* a distributed runtime, with API Gateway, that will seamlessly stretch across product boundaries and cluster boundaries
* toolchain to aid, fast-track application development
* a programmatic library to provide a cloud native development paradigm
* a single tool to hold all of the above together

In essence, what products want is not K8s, not be limited by K8s, but rather to build on top of K8s.

Nexus SDK is our answer to these prayers :tada: :innocent:

![WhyNexus](.content/images/WhyNexus.png)

## What's in the box ?

* [Simple / intuitive DSL](Datamodel/DSL/README.md) to specify Nexus Datamodel.
* [Nexus compiler](.content/images/NexusCompiler.png) that understands Nexus DSL and generates datamodel spec and libraries.
* Nexus Datamodel implementation using K8s CRDs.
* [Nexus runtime](design/Nexus-Runtime.md) to host Nexus Datamodel.
* Ability to consume Nexus Datamodel using standard / opensource K8s libraries.
* [Nexus CLI](design/NexusCLI.md) that is a command line interface that is uber utility to interface with framework and SDK.

## Typical Application Workflow

![ApplicationWorkflow](.content/images/ApplicationWorkflow.png)

## **Nexus SDK Sessions Recordings**

Please follow this link if you would like to understand and deep dive into the nexus SDK and its components.

https://confluence.eng.vmware.com/pages/viewpage.action?spaceKey=NSBU&title=Nexus+SDK+Recordings

## Support

Reach out to Platform Team on [#nexus-sdk](https://vmware.slack.com/archives/C017KTHQ10X) slack channel for additional info and support.
13 changes: 13 additions & 0 deletions docs/_internal/cors_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: domain.nexus.vmware.com/v1
kind: CORSConfig
metadata:
name: default
labels:
nexuses.api.nexus.vmware.com: default
configs.config.nexus.vmware.com: default
apigateways.apigateway.nexus.vmware.com: default
spec:
origins:
- http://domain
headers:
- X-Origin
14 changes: 14 additions & 0 deletions docs/_internal/cors_headers_verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -x

sleep 5
ORIGIN=$(curl -X OPTIONS 'http://localhost:5001/api/v1/namespaces/' -H 'Origin: http://domain' -H "Access-Control-Request-Method: GET" -s --head | grep 'Access-Control-Allow-Origin'| uniq | wc -l)

if [ $ORIGIN -eq 1 ]; then
echo "CORS Header added"
exit 0
else
exit 1
fi

41 changes: 41 additions & 0 deletions docs/_internal/header_based_routing_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -x

expected=$1

RETRY=4
ATTEMPT=0
echo 'testing header-based routing with a valid header...'
while [ $ATTEMPT -ne $RETRY ]; do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" localhost:10000/leaders?orgchart.Root=default -H "x-tenant:t-1")
if [ "$STATUS" == "$expected" ] ; then
echo "SUCCESS"
break
else
ATTEMPT=$((ATTEMPT + 1))
if [ $ATTEMPT -eq $RETRY ]; then
echo "FAILED: $STATUS. expected $expected"
exit 1
else
sleep 5
fi
fi
done

echo 'testing header-based routing with an invalid header...'
while [ $ATTEMPT -ne $RETRY ]; do
STATUS=$(curl -s -o /dev/null -w "%{http_code}" localhost:10000/leaders?orgchart.Root=default -H "x-tenant:asdf")
if [ "$STATUS" == "400" ] ; then
echo "SUCCESS"
break
else
ATTEMPT=$((ATTEMPT + 1))
if [ $ATTEMPT -eq $RETRY ]; then
echo "FAILED: $STATUS. expected 400"
exit 1
else
sleep 5
fi
fi
done
77 changes: 77 additions & 0 deletions docs/_internal/leader_controller.go.patched_imported
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
Copyright 2022.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package managementvmwareorg

import (
"context"
"fmt"
"os"
"path/filepath"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"

managementvmwareorgv1 "gitlab.eng.vmware.com/nsx-allspark_users/nexus-sdk/datamodel-examples.git/org-chart/build/apis/management.vmware.org/v1"
)

// LeaderReconciler reconciles a Leader object
type LeaderReconciler struct {
client.Client
Scheme *runtime.Scheme
}

//+kubebuilder:rbac:groups=management.vmware.org.test-app-imported-dm.com,resources=leaders,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=management.vmware.org.test-app-imported-dm.com,resources=leaders/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=management.vmware.org.test-app-imported-dm.com,resources=leaders/finalizers,verbs=update

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
// TODO(user): Modify the Reconcile function to compare the state specified by
// the Leader object against the actual cluster state, and then
// perform operations to make the cluster state reflect the state specified by
// the user.
//
// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.2/pkg/reconcile
func (r *LeaderReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
_ = log.FromContext(ctx)

// Business Logic: An event has occurred on the Leader Node.
var leader managementvmwareorgv1.Leader
if err := r.Get(ctx, req.NamespacedName, &leader); err != nil {
return ctrl.Result{}, client.IgnoreNotFound(err)
}
fmt.Printf("Received event for leader node: Name %s Spec %v\n", leader.Name, leader.Spec)

// create a file type_name
filename := leader.Kind + "_" + leader.ObjectMeta.Name
err := os.WriteFile(filepath.Join("/tmp", filename), []byte{}, 0644)
if err != nil {
fmt.Printf("Failed to write to /tmp/%s due to error: %v\n", filename, err)
}

return ctrl.Result{}, nil
}

// SetupWithManager sets up the controller with the Manager.
func (r *LeaderReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&managementvmwareorgv1.Leader{}).
Complete(r)
}
Loading