Skip to content

Commit

Permalink
Merge pull request #1 from chain4travel/camino-operator
Browse files Browse the repository at this point in the history
Use camino-operator instead caminogo-operator
  • Loading branch information
c4t-ag authored May 17, 2022
2 parents b8841b8 + b39fca9 commit dd151d8
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
name: Lint tests
runs-on: ubuntu-latest
steps:
- name: Allow access to caminogo-operator repo
- name: Allow access to camino-operator repo
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.CAMBOT_PAT }}
run: git config --global url."https://${GITHUB_ACCESS_TOKEN}@github.com/chain4travel/caminogo-operator".insteadOf "https://github.com/chain4travel/caminogo-operator"
run: git config --global url."https://${GITHUB_ACCESS_TOKEN}@github.com/chain4travel/camino-operator".insteadOf "https://github.com/chain4travel/camino-operator"
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
Expand All @@ -32,10 +32,10 @@ jobs:
runs-on: ubuntu-latest
concurrency: node_fence
steps:
- name: Allow access to caminogo-operator repo
- name: Allow access to camino-operator repo
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.CAMBOT_PAT }}
run: git config --global url."https://${GITHUB_ACCESS_TOKEN}@github.com/chain4travel/caminogo-operator".insteadOf "https://github.com/chain4travel/caminogo-operator"
run: git config --global url."https://${GITHUB_ACCESS_TOKEN}@github.com/chain4travel/camino-operator".insteadOf "https://github.com/chain4travel/camino-operator"
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
Expand Down
10 changes: 5 additions & 5 deletions examples/k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Standard Kubernetes is best suited for *stateless* applications.
To allow for stateful applications, the **Operator** pattern has been introduced into the kubernetes world [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/).

This means that in order to successfully run an camino network with this network runner tool on kubernetes, a "domain-specific" implementation of the pattern is required.
This implementation can be found at [caminogo-operator](https://github.com/chain4travel/caminogo-operator).
This implementation can be found at [camino-operator](https://github.com/chain4travel/camino-operator).

There only needs to be running **1 operator instance** per kubernetes namespace.
Therefore it is very important to distinguish between:
Expand All @@ -30,7 +30,7 @@ Therefore it is very important to distinguish between:
### Github action
If running in a cloud provided (for Ava Labs, typically AWS), then the **devops** team is responsible for setting up the required infrastructure.

**Devops would be deploying the `caminogo-operator`**.
**Devops would be deploying the `camino-operator`**.

The normal operation is to create a github action which triggers the deployment to the kubernetes cluster in the cloud.
An example of such a github action can be found at `examples/github` **TODO**.
Expand All @@ -45,7 +45,7 @@ Usually there would be nothing else to be done for the deployment other than imp

### Without github action
If a deployment without a github action should be required, then devops involvement is likewise required.
They also would deploy the `caminogo-operator` and provide necessary deployment information (namespace etc.).
They also would deploy the `camino-operator` and provide necessary deployment information (namespace etc.).

The network runner can then analogously be deployed either via self-contained pod or a `main` binary. Both need to have the required permissions.

Expand All @@ -61,8 +61,8 @@ To run a local kubernetes environment:
3. Install `kubectx` to allow to set an easy default environment: [kubectx](https://github.com/ahmetb/kubectx)
4. Set the `$KUBECONFIG` environment variable to read the `k3s` environment: `export KUBECONFIG=/etc/rancher/k3s/k3s.yaml` (put this into your `.profile` or preferred environment persistance method). Make sure this variable is present in all terminals used for this tool.
5. Run `kubectx` to check that the environment is fine (it should print `default` if there are no other kubernetes configs, otherwise, check the `kubectx` docs).
6. **Run the caminogo-operator locally**
6a. Clone the repository: `github.com/chain4travel/caminogo-operator`
6. **Run the camino-operator locally**
6a. Clone the repository: `github.com/chain4travel/camino-operator`
6b. Run `make install` followed by `make run`. This should be everything needed.
7. Install the service account, role and roleconfigs for the network runner pod: `kubectl apply -f examples/k8s/svc-rbac.yaml`.
8. Build this app as a pod: `docker build -f ./examples/k8s/Dockerfile -t k8s-netrunner:alpha .`. If you use a different app name than `k8s-netrunner` and/or tag `alpha`, the `examples/k8s/simple-network-pod.yaml` file needs to be updated accordingly.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/chain4travel/camino-network-runner
go 1.17

require (
github.com/chain4travel/camino-operator v0.2.0
github.com/chain4travel/caminoethvm v0.1.2-rc1
github.com/chain4travel/caminogo v0.2.0
github.com/chain4travel/caminogo-operator v0.1.0
github.com/ethereum/go-ethereum v1.10.16
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.2
github.com/onsi/ginkgo/v2 v2.1.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chain4travel/camino-operator v0.2.0 h1:Rjnp9ZAh4/0nR0jx5pxuABQ4I5wYoozNO4bYEsCGDrI=
github.com/chain4travel/camino-operator v0.2.0/go.mod h1:AaPMcC0iP0o/a37X/BaEnUp+v8SHgEqP8vI0PB+axXY=
github.com/chain4travel/caminoethvm v0.1.2-rc1 h1:SooVM2vFmygc7mqCFzMNNT0l6xl+09d7U0uXJsVc1Yk=
github.com/chain4travel/caminoethvm v0.1.2-rc1/go.mod h1:sJ070HuN5qhEEGzBc8lmX4l0Zx8Wg0bpHLkwTwYJX4I=
github.com/chain4travel/caminogo v0.2.0 h1:77/bR/c6oA9BW8YIVqkCVhIG76X6WRZhGVzjqswWgx4=
github.com/chain4travel/caminogo v0.2.0/go.mod h1:phXVVpkhyFSS5fl6hCUMaaPJ5P4NZ5AqcFwROhjJiZ4=
github.com/chain4travel/caminogo-operator v0.1.0 h1:Ifw+lgV78FaK9QWpJxG/WrwAyCko/axugLFNbEpvRMA=
github.com/chain4travel/caminogo-operator v0.1.0/go.mod h1:FcWFZUXgPi89vY9ieXrIdJoMMILFFp3ClFpQJ6IBr38=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down
10 changes: 5 additions & 5 deletions k8s/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/chain4travel/caminogo/utils/logging"
"golang.org/x/sync/errgroup"

k8sapi "github.com/chain4travel/caminogo-operator/api/v1alpha1"
k8sapi "github.com/chain4travel/camino-operator/api/v1alpha1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
Expand All @@ -39,7 +39,7 @@ const (
nodeReachableTimeout = 2 * time.Minute
// Time between checks to see if a node is reachable
nodeReachableRetryFreq = 3 * time.Second
// Prefix the caminogo-operator uses to pass params to caminogo nodes
// Prefix the camino-operator uses to pass params to caminogo nodes
envVarPrefix = "AVAGO_"
)

Expand Down Expand Up @@ -275,7 +275,7 @@ func (a *networkImpl) AddNode(cfg node.Config) (node.Node, error) {
}

a.log.Debug("Launching new node %s to network...", cfg.Name)
if err := a.launchNodes([]*k8sapi.Caminogo{nodeSpec}); err != nil {
if err := a.launchNodes([]*k8sapi.Camino{nodeSpec}); err != nil {
return nil, err
}

Expand Down Expand Up @@ -349,7 +349,7 @@ func (net *networkImpl) isStopped() bool {

// Creates the given nodes and blocks until they're all reachable.
// Assumes [a.nodesLock] isn't held.
func (a *networkImpl) launchNodes(nodeSpecs []*k8sapi.Caminogo) error {
func (a *networkImpl) launchNodes(nodeSpecs []*k8sapi.Camino) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand All @@ -368,7 +368,7 @@ func (a *networkImpl) launchNodes(nodeSpecs []*k8sapi.Caminogo) error {

// Create the given node in k8s and block until it's reachable.
// Assumes [a.nodesLock] isn't held.
func (a *networkImpl) launchNode(ctx context.Context, nodeSpec *k8sapi.Caminogo) error {
func (a *networkImpl) launchNode(ctx context.Context, nodeSpec *k8sapi.Camino) error {
ctx, cancel := context.WithTimeout(ctx, nodeReachableTimeout)
defer cancel()

Expand Down
4 changes: 2 additions & 2 deletions k8s/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/chain4travel/caminogo/utils/constants"
"github.com/chain4travel/caminogo/utils/logging"

k8sapi "github.com/chain4travel/caminogo-operator/api/v1alpha1"
k8sapi "github.com/chain4travel/camino-operator/api/v1alpha1"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -131,7 +131,7 @@ func newMockK8sClient() k8scli.Client {
client := &mocks.Client{}
client.On("Get", mock.Anything, mock.Anything, mock.Anything).Run(
func(args mock.Arguments) {
arg := args.Get(2).(*k8sapi.Caminogo)
arg := args.Get(2).(*k8sapi.Camino)
arg.Status.NetworkMembersURI = []string{"localhost"}
}).Return(nil)
client.On("Delete", mock.Anything, mock.Anything, mock.Anything).Return(nil)
Expand Down
6 changes: 3 additions & 3 deletions k8s/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

"github.com/chain4travel/camino-network-runner/api"
"github.com/chain4travel/camino-network-runner/network/node"
k8sapi "github.com/chain4travel/caminogo-operator/api/v1alpha1"
k8sapi "github.com/chain4travel/camino-operator/api/v1alpha1"
"github.com/chain4travel/caminogo/ids"
"github.com/chain4travel/caminogo/network/peer"
"github.com/chain4travel/caminogo/snow/networking/router"
Expand Down Expand Up @@ -47,7 +47,7 @@ type Node struct {
// Use to send API calls to this node
apiClient api.Client
// K8s description of this node
k8sObjSpec *k8sapi.Caminogo
k8sObjSpec *k8sapi.Camino
}

// AttachPeer see Network
Expand Down Expand Up @@ -89,6 +89,6 @@ func (n *Node) GetAPIPort() uint16 {

// GetK8sObjSpec returns the kubernetes object spec
// representation of this node
func (n *Node) GetK8sObjSpec() *k8sapi.Caminogo {
func (n *Node) GetK8sObjSpec() *k8sapi.Camino {
return n.k8sObjSpec
}
16 changes: 8 additions & 8 deletions k8s/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/chain4travel/camino-network-runner/network/node"
"github.com/chain4travel/camino-network-runner/utils"
k8sapi "github.com/chain4travel/caminogo-operator/api/v1alpha1"
k8sapi "github.com/chain4travel/camino-operator/api/v1alpha1"
"github.com/chain4travel/caminogo/config"
"github.com/chain4travel/caminogo/utils/logging"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -97,7 +97,7 @@ func buildNodeEnv(log logging.Logger, genesis []byte, c node.Config) ([]corev1.E
}

// Takes a node's config and genesis and returns the node as a k8s object spec
func buildK8sObjSpec(log logging.Logger, genesis []byte, c node.Config) (*k8sapi.Caminogo, error) {
func buildK8sObjSpec(log logging.Logger, genesis []byte, c node.Config) (*k8sapi.Camino, error) {
env, err := buildNodeEnv(log, genesis, c)
if err != nil {
return nil, err
Expand All @@ -117,7 +117,7 @@ func buildK8sObjSpec(log logging.Logger, genesis []byte, c node.Config) (*k8sapi
return nil, err
}

return &k8sapi.Caminogo{
return &k8sapi.Camino{
TypeMeta: metav1.TypeMeta{
Kind: k8sConf.Kind,
APIVersion: k8sConf.APIVersion,
Expand All @@ -126,7 +126,7 @@ func buildK8sObjSpec(log logging.Logger, genesis []byte, c node.Config) (*k8sapi
Name: k8sConf.Identifier,
Namespace: k8sConf.Namespace,
},
Spec: k8sapi.CaminogoSpec{
Spec: k8sapi.CaminoSpec{
BootstrapperURL: "",
DeploymentName: k8sConf.Identifier,
Image: k8sConf.Image,
Expand Down Expand Up @@ -158,7 +158,7 @@ func validateObjectSpec(k8sobj ObjectSpec) error {
case k8sobj.APIVersion == "":
return errors.New("APIVersion should not be empty")
case k8sobj.Kind != "Caminogo":
// only "CaminoGo" currently supported -- mandated by caminogo-operator
// only "CaminoGo" currently supported -- mandated by camino-operator
return fmt.Errorf("expected \"Caminogo\" but got %q", k8sobj.Kind)
case k8sobj.Namespace == "":
return errors.New("namespace should be defined to avoid unintended consequences")
Expand All @@ -172,9 +172,9 @@ func validateObjectSpec(k8sobj ObjectSpec) error {
// Takes the genesis of a network and node configs and returns:
// 1) The beacon nodes
// 2) The non-beacon nodes
// as caminogo-operator compatible descriptions.
// as camino-operator compatible descriptions.
// May return nil slices.
func createDeploymentFromConfig(params networkParams) ([]*k8sapi.Caminogo, []*k8sapi.Caminogo, error) {
func createDeploymentFromConfig(params networkParams) ([]*k8sapi.Camino, []*k8sapi.Camino, error) {
// Give each flag in the network config to each node's config.
// If a flag is defined in both the network config and the node config,
// the value given in the node config takes precedence.
Expand All @@ -196,7 +196,7 @@ func createDeploymentFromConfig(params networkParams) ([]*k8sapi.Caminogo, []*k8
}
}

var beacons, nonBeacons []*k8sapi.Caminogo
var beacons, nonBeacons []*k8sapi.Camino
names := make(map[string]struct{})
for _, nodeConfig := range params.conf.NodeConfigs {
spec, err := buildK8sObjSpec(params.log, []byte(params.conf.Genesis), nodeConfig)
Expand Down

0 comments on commit dd151d8

Please sign in to comment.