Skip to content

Commit d0dc098

Browse files
authored
Merge pull request #257 from oribon/bgpsessionstate
Add BGPSessionState
2 parents 4f6984c + dfeb889 commit d0dc098

29 files changed

+2018
-90
lines changed

API-DOCS.md

+53
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Package v1alpha1 contains API Schema definitions for the frrk8s v1alpha1 API group
1010

1111
### Resource Types
12+
- [BGPSessionState](#bgpsessionstate)
1213
- [FRRConfiguration](#frrconfiguration)
1314
- [FRRNodeState](#frrnodestate)
1415

@@ -105,6 +106,58 @@ _Appears in:_
105106
| `bfdProfiles` _[BFDProfile](#bfdprofile) array_ | BFDProfiles is the list of bfd profiles to be used when configuring the neighbors. | | |
106107

107108

109+
#### BGPSessionState
110+
111+
112+
113+
BGPSessionState exposes the status of a BGP Session from the FRR instance running on the node.
114+
115+
116+
117+
118+
119+
| Field | Description | Default | Validation |
120+
| --- | --- | --- | --- |
121+
| `apiVersion` _string_ | `frrk8s.metallb.io/v1beta1` | | |
122+
| `kind` _string_ | `BGPSessionState` | | |
123+
| `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | |
124+
| `spec` _[BGPSessionStateSpec](#bgpsessionstatespec)_ | | | |
125+
| `status` _[BGPSessionStateStatus](#bgpsessionstatestatus)_ | | | |
126+
127+
128+
#### BGPSessionStateSpec
129+
130+
131+
132+
BGPSessionStateSpec defines the desired state of BGPSessionState.
133+
134+
135+
136+
_Appears in:_
137+
- [BGPSessionState](#bgpsessionstate)
138+
139+
140+
141+
#### BGPSessionStateStatus
142+
143+
144+
145+
BGPSessionStateStatus defines the observed state of BGPSessionState.
146+
147+
148+
149+
_Appears in:_
150+
- [BGPSessionState](#bgpsessionstate)
151+
152+
| Field | Description | Default | Validation |
153+
| --- | --- | --- | --- |
154+
| `bgpStatus` _string_ | | | |
155+
| `bfdStatus` _string_ | | | |
156+
| `node` _string_ | | | |
157+
| `peer` _string_ | | | |
158+
| `vrf` _string_ | | | |
159+
160+
108161
#### CommunityPrefixes
109162

110163

Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ COPY cmd/main.go cmd/main.go
1313
COPY api/ api/
1414
COPY internal/ internal/
1515
COPY frr-tools/metrics ./frr-tools/metrics/
16+
COPY frr-tools/status ./frr-tools/status/
1617

1718
ARG TARGETARCH
1819
ARG TARGETOS
@@ -35,6 +36,12 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
3536
-ldflags "-X 'frr-k8s/internal/version.gitCommit=${GIT_COMMIT}' -X 'frr-k8s/metallb/internal/version.gitBranch=${GIT_BRANCH}'" \
3637
frr-tools/metrics/exporter.go \
3738
&& \
39+
# build frr status
40+
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=$VARIANT \
41+
go build -v -o /build/frr-status \
42+
-ldflags "-X 'frr-k8s/internal/version.gitCommit=${GIT_COMMIT}' -X 'frr-k8s/metallb/internal/version.gitBranch=${GIT_BRANCH}'" \
43+
frr-tools/status/exporter.go \
44+
&& \
3845
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GOARM=$VARIANT \
3946
go build -v -o /build/frr-k8s \
4047
-ldflags "-X 'frr-k8s/internal/version.gitCommit=${GIT_COMMIT}' -X 'frr-k8s/internal/version.gitBranch=${GIT_BRANCH}'" \
@@ -45,6 +52,7 @@ FROM docker.io/alpine:latest
4552

4653
COPY --from=builder /build/frr-k8s /frr-k8s
4754
COPY --from=builder /build/frr-metrics /frr-metrics
55+
COPY --from=builder /build/frr-status /frr-status
4856
COPY frr-tools/reloader/frr-reloader.sh /frr-reloader.sh
4957
COPY LICENSE /
5058

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ deploy-controller: kubectl kustomize ## Deploy controller to the K8s cluster spe
166166

167167
$(KUSTOMIZE) build config/$(KUSTOMIZE_LAYER) | \
168168
sed '/--log-level/a\ - --always-block=192.167.9.0/24,fc00:f553:ccd:e799::/64' |\
169-
sed 's/--log-level=info/--log-level='$(LOGLEVEL)'/' | $(KUBECTL) apply -f -
169+
sed 's/--log-level=info/--log-level='$(LOGLEVEL)'/' |\
170+
sed '/--pod-name/a\ - --poll-interval=5s' | $(KUBECTL) apply -f -
170171
sleep 2s # wait for daemonset to be created
171172
$(KUBECTL) -n ${NAMESPACE} wait --for=condition=Ready --all pods --timeout 300s
172173

@@ -176,7 +177,7 @@ deploy-helm: helm deploy-cluster deploy-prometheus
176177
$(KUBECTL) label ns ${NAMESPACE} pod-security.kubernetes.io/enforce=privileged
177178
$(HELM) install frrk8s charts/frr-k8s/ --set frrk8s.image.tag=${IMG_TAG} --set frrk8s.logLevel=debug --set prometheus.rbacPrometheus=true \
178179
--set prometheus.serviceAccount=prometheus-k8s --set prometheus.namespace=monitoring --set prometheus.serviceMonitor.enabled=true \
179-
--set frrk8s.alwaysBlock='192.167.9.0/24\,fc00:f553:ccd:e799::/64' --namespace ${NAMESPACE} $(HELM_ARGS)
180+
--set frrk8s.alwaysBlock='192.167.9.0/24\,fc00:f553:ccd:e799::/64' --set frrk8s.frrStatus.pollInterval='5s' --namespace ${NAMESPACE} $(HELM_ARGS)
180181
sleep 2s # wait for daemonset to be created
181182
$(KUBECTL) -n ${NAMESPACE} wait --for=condition=Ready --all pods --timeout 300s
182183

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
Copyright 2023.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// BGPSessionStateSpec defines the desired state of BGPSessionState.
24+
type BGPSessionStateSpec struct {
25+
}
26+
27+
// BGPSessionStateStatus defines the observed state of BGPSessionState.
28+
type BGPSessionStateStatus struct {
29+
BGPStatus string `json:"bgpStatus,omitempty"`
30+
BFDStatus string `json:"bfdStatus,omitempty"`
31+
Node string `json:"node,omitempty"`
32+
Peer string `json:"peer,omitempty"`
33+
VRF string `json:"vrf,omitempty"`
34+
}
35+
36+
//+kubebuilder:object:root=true
37+
//+kubebuilder:subresource:status
38+
39+
// BGPSessionState exposes the status of a BGP Session from the FRR instance running on the node.
40+
type BGPSessionState struct {
41+
metav1.TypeMeta `json:",inline"`
42+
metav1.ObjectMeta `json:"metadata,omitempty"`
43+
44+
Spec BGPSessionStateSpec `json:"spec,omitempty"`
45+
Status BGPSessionStateStatus `json:"status,omitempty"`
46+
}
47+
48+
//+kubebuilder:object:root=true
49+
50+
// BGPSessionStateList contains a list of BGPSessionState.
51+
type BGPSessionStateList struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ListMeta `json:"metadata,omitempty"`
54+
Items []BGPSessionState `json:"items"`
55+
}
56+
57+
func init() {
58+
SchemeBuilder.Register(&BGPSessionState{}, &BGPSessionStateList{})
59+
}

api/v1beta1/zz_generated.deepcopy.go

+89
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/frr-k8s/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Kubernetes: `>= 1.19.0-0`
3636
| frrk8s.frr.resources | object | `{}` | |
3737
| frrk8s.frr.secureMetricsPort | int | `9141` | |
3838
| frrk8s.frrMetrics.resources | object | `{}` | |
39+
| frrk8s.frrStatus.pollInterval | string | `"2m"` | |
40+
| frrk8s.frrStatus.resources | object | `{}` | |
3941
| frrk8s.image.pullPolicy | string | `nil` | |
4042
| frrk8s.image.repository | string | `"quay.io/metallb/frr-k8s"` | |
4143
| frrk8s.image.tag | string | `nil` | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.14.0
7+
name: bgpsessionstates.frrk8s.metallb.io
8+
spec:
9+
group: frrk8s.metallb.io
10+
names:
11+
kind: BGPSessionState
12+
listKind: BGPSessionStateList
13+
plural: bgpsessionstates
14+
singular: bgpsessionstate
15+
scope: Namespaced
16+
versions:
17+
- name: v1beta1
18+
schema:
19+
openAPIV3Schema:
20+
description: BGPSessionState exposes the status of a BGP Session from the
21+
FRR instance running on the node.
22+
properties:
23+
apiVersion:
24+
description: |-
25+
APIVersion defines the versioned schema of this representation of an object.
26+
Servers should convert recognized schemas to the latest internal value, and
27+
may reject unrecognized values.
28+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
29+
type: string
30+
kind:
31+
description: |-
32+
Kind is a string value representing the REST resource this object represents.
33+
Servers may infer this from the endpoint the client submits requests to.
34+
Cannot be updated.
35+
In CamelCase.
36+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
37+
type: string
38+
metadata:
39+
type: object
40+
spec:
41+
description: BGPSessionStateSpec defines the desired state of BGPSessionState.
42+
type: object
43+
status:
44+
description: BGPSessionStateStatus defines the observed state of BGPSessionState.
45+
properties:
46+
bfdStatus:
47+
type: string
48+
bgpStatus:
49+
type: string
50+
node:
51+
type: string
52+
peer:
53+
type: string
54+
vrf:
55+
type: string
56+
type: object
57+
type: object
58+
served: true
59+
storage: true
60+
subresources:
61+
status: {}

0 commit comments

Comments
 (0)