Skip to content

Commit

Permalink
Update default cni for get cluster calls (#72)
Browse files Browse the repository at this point in the history
* Set default cni for get cluster calls
* Updated release doc
  • Loading branch information
Inbaraj-S authored Jun 4, 2024
1 parent b6d7df4 commit d2712dd
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ metadata:
name: oci-native-ingress-controller
namespace: native-ingress-controller-system
labels:
helm.sh/chart: oci-native-ingress-controller-1.3.5
helm.sh/chart: oci-native-ingress-controller-1.3.6
app.kubernetes.io/name: oci-native-ingress-controller
app.kubernetes.io/instance: oci-native-ingress-controller
app.kubernetes.io/version: "1.3.5"
app.kubernetes.io/version: "1.3.6"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
Expand Down Expand Up @@ -51,7 +51,7 @@ spec:
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
image: "ghcr.io/oracle/oci-native-ingress-controller:v1.3.5"
image: "ghcr.io/oracle/oci-native-ingress-controller:v1.3.6"
imagePullPolicy: Always
args:
- --lease-lock-name=oci-native-ingress-controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ kind: ClusterRole
metadata:
name: oci-native-ingress-controller-role
labels:
helm.sh/chart: oci-native-ingress-controller-1.3.5
helm.sh/chart: oci-native-ingress-controller-1.3.6
app.kubernetes.io/name: oci-native-ingress-controller
app.kubernetes.io/instance: oci-native-ingress-controller
app.kubernetes.io/version: "1.3.5"
app.kubernetes.io/version: "1.3.6"
app.kubernetes.io/managed-by: Helm
rules:
- apiGroups: [""]
Expand Down Expand Up @@ -48,10 +48,10 @@ kind: ClusterRoleBinding
metadata:
name: oci-native-ingress-controller-rolebinding
labels:
helm.sh/chart: oci-native-ingress-controller-1.3.5
helm.sh/chart: oci-native-ingress-controller-1.3.6
app.kubernetes.io/name: oci-native-ingress-controller
app.kubernetes.io/instance: oci-native-ingress-controller
app.kubernetes.io/version: "1.3.5"
app.kubernetes.io/version: "1.3.6"
app.kubernetes.io/managed-by: Helm
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand All @@ -69,10 +69,10 @@ metadata:
name: oci-native-ingress-controller-leader-election-role
namespace: native-ingress-controller-system
labels:
helm.sh/chart: oci-native-ingress-controller-1.3.5
helm.sh/chart: oci-native-ingress-controller-1.3.6
app.kubernetes.io/name: oci-native-ingress-controller
app.kubernetes.io/instance: oci-native-ingress-controller
app.kubernetes.io/version: "1.3.5"
app.kubernetes.io/version: "1.3.6"
app.kubernetes.io/managed-by: Helm
rules:
- apiGroups: ["coordination.k8s.io"]
Expand All @@ -90,10 +90,10 @@ metadata:
name: oci-native-ingress-controller-leader-election-rolebinding
namespace: native-ingress-controller-system
labels:
helm.sh/chart: oci-native-ingress-controller-1.3.5
helm.sh/chart: oci-native-ingress-controller-1.3.6
app.kubernetes.io/name: oci-native-ingress-controller
app.kubernetes.io/instance: oci-native-ingress-controller
app.kubernetes.io/version: "1.3.5"
app.kubernetes.io/version: "1.3.6"
app.kubernetes.io/managed-by: Helm
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ metadata:
name: oci-native-ingress-controller
namespace: native-ingress-controller-system
labels:
helm.sh/chart: oci-native-ingress-controller-1.3.5
helm.sh/chart: oci-native-ingress-controller-1.3.6
app.kubernetes.io/name: oci-native-ingress-controller
app.kubernetes.io/instance: oci-native-ingress-controller
app.kubernetes.io/version: "1.3.5"
app.kubernetes.io/version: "1.3.6"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ metadata:
name: oci-native-ingress-controller
namespace: native-ingress-controller-system
labels:
helm.sh/chart: oci-native-ingress-controller-1.3.5
helm.sh/chart: oci-native-ingress-controller-1.3.6
app.kubernetes.io/name: oci-native-ingress-controller
app.kubernetes.io/instance: oci-native-ingress-controller
app.kubernetes.io/version: "1.3.5"
app.kubernetes.io/version: "1.3.6"
app.kubernetes.io/managed-by: Helm
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ kind: MutatingWebhookConfiguration
metadata:
name: oci-native-ingress-controller-webhook
labels:
helm.sh/chart: oci-native-ingress-controller-1.3.5
helm.sh/chart: oci-native-ingress-controller-1.3.6
app.kubernetes.io/name: oci-native-ingress-controller
app.kubernetes.io/instance: oci-native-ingress-controller
app.kubernetes.io/version: "1.3.5"
app.kubernetes.io/version: "1.3.6"
app.kubernetes.io/managed-by: Helm
annotations:
cert-manager.io/inject-ca-from: native-ingress-controller-system/oci-native-ingress-controller-webhook-serving-cert
Expand Down
4 changes: 2 additions & 2 deletions helm/oci-native-ingress-controller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ apiVersion: v2
name: oci-native-ingress-controller
description: OCI Native Ingress Controller
type: application
version: 1.3.5
appVersion: "1.3.5"
version: 1.3.6
appVersion: "1.3.6"

maintainers:
- name: OKE Foundations team
Expand Down
2 changes: 1 addition & 1 deletion helm/oci-native-ingress-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ image:
repository: ghcr.io/oracle/oci-native-ingress-controller
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: "v1.3.5"
tag: "v1.3.6"

imagePullSecrets: []
nameOverride: ""
Expand Down
3 changes: 1 addition & 2 deletions pkg/server/config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ clusters:
- name: cluster-ckmntg4fska
cluster:
server: https://129.80.70.29:6443
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURpVENDQW5HZ0F3SUJBZ0lSQU5GbG9rWEVxOTgyTGNwUmE4YUxDREF3RFFZSktvWklodmNOQVFFTEJRQXcKWGpFUE1BMEdBMVVFQXd3R1N6aHpJRU5CTVFzd0NRWURWUVFHRXdKVlV6RVBNQTBHQTFVRU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NQYWJHeQpBbnJ1aEJtTVphbWo1MUwvLzhtcVlQckxiZ09BUFlnZEVqb0pFOUJOS1dEbDM3bUl3bmwyUkV1TVNUbkxIdTdQClRzY1ZyazZROGJyS2FtalQrSjA0UHRPSytoMG9QSWUyenZtNStJcVcvQW1ET0FQQWd3WTZ1ZFkvNkllYzUrSUcKZzBjQzZMUDdQK2FMMnhHRXcvYkNJQThaZE44MTB2c05GcE56TS80MkdwL0QvanhiY2R5R3JHMGY2dnFKZ1I1dgo4TjFnR2lzSEtsZktpdE5aT3BVQmNjV3hmY0J4eUUvQzJmZktEOVZLYTdYcjZSQzA5T3cxRFJuUW8waEtab1VmClVKNEY1a28vVnhPUU9jdmhkbmxqSkYxK1cwSnMvWkJuZEdlWUUra1YvZmw1VE9xTjBoZk8xOUlaSWhCSAotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
users:
- name: user-ckmntg4fska
user:
Expand All @@ -17,7 +16,7 @@ users:
- cluster
- generate-token
- --cluster-id
- ocid1.cluster.oc1.iad.aaaaaaaafwztfxvg7aksgmlcjfemq4zoce34x66i3wknnt377ckmntg4fska
- ocid1.cluster.oc1.iad.aaaaaaaafwztfxvg7aks___ckmntg4fska
- --region
- us-ashburn-1
env: []
Expand Down
33 changes: 18 additions & 15 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package server

import (
"context"
"fmt"
"net/http"
"os"

Expand Down Expand Up @@ -148,29 +147,33 @@ func SetUpControllers(opts types.IngressOpts, ingressClassInformer networkinginf
}

func fetchCniType(id string, client *containerengine.ContainerEngineClient) (string, error) {
resp := getCluster(id, client)
return GetCniFromCluster(resp)
}

// Create a request and dependent object(s).
req := containerengine.GetClusterRequest{ClusterId: common.String(id)}

// Send the request using the service client
resp, err := client.GetCluster(context.Background(), req)
if err != nil {
klog.Fatalf("failed to get cluster details: %v", err)
}
cni := resp.Cluster.ClusterPodNetworkOptions

func GetCniFromCluster(resp containerengine.Cluster) (string, error) {
cni := resp.ClusterPodNetworkOptions
for _, n := range cni {
switch n.(type) {
case containerengine.FlannelOverlayClusterPodNetworkOptionDetails:
return string(containerengine.ClusterPodNetworkOptionDetailsCniTypeFlannelOverlay), nil
case containerengine.OciVcnIpNativeClusterPodNetworkOptionDetails:
return string(containerengine.ClusterPodNetworkOptionDetailsCniTypeOciVcnIpNative), nil
default:
return "", fmt.Errorf("unsupported CNI found in Cluster : %v", n)
return string(containerengine.ClusterPodNetworkOptionDetailsCniTypeFlannelOverlay), nil
}
}
return string(containerengine.ClusterPodNetworkOptionDetailsCniTypeFlannelOverlay), nil
}

func getCluster(id string, client *containerengine.ContainerEngineClient) containerengine.Cluster {
// Create a request and dependent object(s).
req := containerengine.GetClusterRequest{ClusterId: common.String(id)}

return "", fmt.Errorf("no CNI found in Cluster")
// Send the request using the service client
resp, err := client.GetCluster(context.Background(), req)
if err != nil {
klog.Fatalf("failed to get cluster details: %v", err)
}
return resp.Cluster
}

func setupClient(ctx context.Context, opts types.IngressOpts, k8client clientset.Interface) *client.ClientProvider {
Expand Down
14 changes: 14 additions & 0 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

. "github.com/onsi/gomega"
. "github.com/oracle/oci-go-sdk/v65/containerengine"
)

func TestKubeConfig(t *testing.T) {
Expand All @@ -12,3 +13,16 @@ func TestKubeConfig(t *testing.T) {
Expect(err == nil && cfg != nil).Should(Equal(true))
Expect(cfg.Host).Should(Equal("https://129.80.70.29:6443"))
}

func TestGetCniFromCluster(t *testing.T) {
RegisterTestingT(t)
ns := make([]ClusterPodNetworkOptionDetails, 1)

// No value test
resp := Cluster{
ClusterPodNetworkOptions: ns,
}
cni, err := GetCniFromCluster(resp)
Expect(cni).Should(Equal(string(ClusterPodNetworkOptionDetailsCniTypeFlannelOverlay)))
Expect(err).Should(BeNil())
}

0 comments on commit d2712dd

Please sign in to comment.