Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

feat(infra): introduce public IP to node info #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
16 changes: 16 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pr

on:
pull_request:
paths:
- "**"
suyuee marked this conversation as resolved.
Show resolved Hide resolved
branches: ["**"]

jobs:
build:
uses: ./.github/workflows/build-docker-image.yaml
secrets: inherit
with:
folder: ./
repo: raven-manager

22 changes: 22 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: push

on:
push:
paths:
- "**"
suyuee marked this conversation as resolved.
Show resolved Hide resolved
branches: ["main"]

jobs:
build:
uses: ./.github/workflows/build-docker-image.yaml
secrets: inherit
with:
folder: ./
repo: raven-manager
tag: latest






17 changes: 17 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: release

on:
push:
tags:
- "*"

jobs:
build:
uses: ./.github/workflows/build-docker-image.yaml
secrets: inherit
with:
folder: ./
repo: raven-manager
tag: ${GITHUB_REF##*/}
commit: ${GITHUB_REF##*/}

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.7.0
creationTimestamp: null
name: blockaffinities.apiregistration.k8s.io
spec:
group: apiregistration.k8s.io
names:
kind: BlockAffinity
listKind: BlockAffinityList
plural: blockaffinities
singular: blockaffinity
scope: Namespaced
versions:
- name: v3
schema:
openAPIV3Schema:
description: BlockAffinity maintains a block affinity's state
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Specification of the BlockAffinity.
properties:
cidr:
type: string
deleted:
description: Deleted indicates that this block affinity is being deleted.
This field is a string for compatibility with older releases that
mistakenly treat this field as a string.
type: string
node:
type: string
state:
type: string
required:
- cidr
- deleted
- node
- state
type: object
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
6 changes: 5 additions & 1 deletion charts/yurt-manager/crds/raven.openyurt.io_gateways.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ spec:
description: NodeName is the Node host name.
type: string
privateIP:
description: PrivateIP is the node private ip address
description: PrivateIP is the node private ip address in lepton cluster
type: string
publicIP:
description: 'Node PublicIP: satellite nodes need to build vxlan connctions using their public IPs;'
type: string
subnets:
description: Subnets is the pod ip range of the node
Expand All @@ -295,6 +298,7 @@ spec:
required:
- nodeName
- privateIP
- publicIP
- subnets
type: object
type: array
Expand Down
26 changes: 4 additions & 22 deletions pkg/apis/calico/v3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pkg/apis/raven/v1beta1/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ type Endpoint struct {
type NodeInfo struct {
// NodeName is the Node host name.
NodeName string `json:"nodeName"`
// PrivateIP is the node private ip address
// PrivateIP is the node private ip address in lepton cluster
PrivateIP string `json:"privateIP"`
// Subnets is the pod ip range of the node
Subnets []string `json:"subnets"`
// Node PublicIP: satellite nodes need to build vxlan connctions
// using their public IPs;
PublicIP string `json:"publicIP"`
}

// GatewayStatus defines the observed state of Gateway
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,17 @@ func (r *ReconcileGateway) Reconcile(ctx context.Context, req reconcile.Request)
klog.ErrorS(err, "unable to get podCIDR")
return reconcile.Result{}, err
}
publicIP := ""
publicIP, err = utils.GetLeptonSatelliteNodePublicIP(v)
if err != nil {
klog.ErrorS(err, "unable to get node public IP")
return reconcile.Result{}, err
}
nodes = append(nodes, ravenv1beta1.NodeInfo{
NodeName: v.Name,
PrivateIP: utils.GetNodeInternalIP(v),
Subnets: podCIDRs,
PublicIP: publicIP,
})
}
sort.Slice(nodes, func(i, j int) bool { return nodes[i].NodeName < nodes[j].NodeName })
Expand Down
12 changes: 12 additions & 0 deletions pkg/yurtmanager/controller/raven/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const (
WorkingNamespace = "kube-system"
RavenGlobalConfig = "raven-cfg"
LabelCurrentGatewayEndpoints = "raven.openyurt.io/endpoints-name"
LabelLeptonSatellitePublicIP = "lepton.ai/provider-public-ip"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe still use the openyurt namespace?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have this label on our edge nodes, need to rename it for all our edge nodes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @gyuho wdyt?

GatewayProxyInternalService = "x-raven-proxy-internal-svc"
GatewayProxyServiceNamePrefix = "x-raven-proxy-svc"
GatewayTunnelServiceNamePrefix = "x-raven-tunnel-svc"
Expand Down Expand Up @@ -67,6 +68,17 @@ func GetNodeInternalIP(node corev1.Node) string {
return ip
}

func GetLeptonSatelliteNodePublicIP(node corev1.Node) (string, error) {
suyuee marked this conversation as resolved.
Show resolved Hide resolved
ip, ok := node.Labels[LabelLeptonSatellitePublicIP]
if !ok {
return "", fmt.Errorf("Failed to get public ip, no label %s on node %s", LabelLeptonSatellitePublicIP, node.Name)
}
if net.ParseIP(ip) == nil {
return "", fmt.Errorf("Failed to get public ip, invalid public IP label %s, %s on node %s", LabelLeptonSatellitePublicIP, ip, node.Name)
}
return ip, nil
}

// AddGatewayToWorkQueue adds the Gateway the reconciler's workqueue
func AddGatewayToWorkQueue(gwName string,
q workqueue.RateLimitingInterface) {
Expand Down
Loading