Skip to content

Commit 12742a4

Browse files
alacukuadamjensenbot
authored andcommitted
chore(liqoctl): move proxy to helm chart
The deployment of the proxy used in liqoctl connect has been moved from the liqoctl tool to the helm chart
1 parent ec8d756 commit 12742a4

File tree

10 files changed

+209
-263
lines changed

10 files changed

+209
-263
lines changed

deployments/liqo/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@
6868
| networkManager.pod.extraArgs | list | `[]` | networkManager pod extra arguments |
6969
| networkManager.pod.labels | object | `{}` | networkManager pod labels |
7070
| openshiftConfig.enable | bool | `false` | enable the OpenShift support |
71+
| proxy.config.listeningPort | int | `8118` | port used by envoy proxy |
72+
| proxy.imageName | string | `"envoyproxy/envoy:v1.21.0"` | proxy image repository |
73+
| proxy.pod.annotations | object | `{}` | proxy pod annotations |
74+
| proxy.pod.extraArgs | list | `[]` | proxy pod extra arguments |
75+
| proxy.pod.labels | object | `{}` | proxy pod labels |
76+
| proxy.service.annotations | object | `{}` | |
77+
| proxy.service.type | string | `"ClusterIP"` | |
7178
| pullPolicy | string | `"IfNotPresent"` | The pullPolicy for liqo pods |
7279
| route.imageName | string | `"liqo/liqonet"` | route image repository |
7380
| route.pod.annotations | object | `{}` | route pod annotations |
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
{{- $proxyConfig := (merge (dict "name" "proxy" "module" "networking") .) -}}
3+
4+
apiVersion: v1
5+
kind: ConfigMap
6+
metadata:
7+
name: {{ include "liqo.prefixedName" $proxyConfig }}
8+
{{- if .Values.proxy.service.annotations }}
9+
annotations:
10+
{{- toYaml .Values.proxy.service.annotations | nindent 4 }}
11+
{{- end}}
12+
labels:
13+
{{- include "liqo.labels" $proxyConfig | nindent 4 }}
14+
data:
15+
config: |
16+
admin:
17+
address:
18+
socket_address:
19+
protocol: TCP
20+
address: 0.0.0.0
21+
port_value: 9901
22+
static_resources:
23+
listeners:
24+
- name: listener_http
25+
address:
26+
socket_address:
27+
protocol: TCP
28+
address: 0.0.0.0
29+
port_value: {{ .Values.proxy.config.listeningPort }}
30+
access_log:
31+
name: envoy.access_loggers.file
32+
typed_config:
33+
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
34+
path: /dev/stdout
35+
filter_chains:
36+
- filters:
37+
- name: envoy.filters.network.http_connection_manager
38+
typed_config:
39+
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
40+
stat_prefix: ingress_http
41+
route_config:
42+
name: local_route
43+
virtual_hosts:
44+
- name: local_service
45+
domains:
46+
- "*"
47+
routes:
48+
- match:
49+
connect_matcher:
50+
{}
51+
route:
52+
cluster: api_server
53+
upgrade_configs:
54+
- upgrade_type: CONNECT
55+
connect_config:
56+
{}
57+
http_filters:
58+
- name: envoy.filters.http.router
59+
clusters:
60+
- name: api_server
61+
connect_timeout: 1.25s
62+
type: STRICT_DNS
63+
respect_dns_ttl: true
64+
dns_lookup_family: V4_ONLY
65+
dns_refresh_rate: 300s
66+
lb_policy: ROUND_ROBIN
67+
load_assignment:
68+
cluster_name: api_server
69+
endpoints:
70+
- lb_endpoints:
71+
- endpoint:
72+
address:
73+
socket_address:
74+
address: kubernetes.default
75+
port_value: 443
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
{{- $proxyConfig := (merge (dict "name" "proxy" "module" "networking") .) -}}
3+
4+
apiVersion: apps/v1
5+
kind: Deployment
6+
metadata:
7+
labels:
8+
{{- include "liqo.labels" $proxyConfig | nindent 4 }}
9+
name: {{ include "liqo.prefixedName" $proxyConfig }}
10+
spec:
11+
replicas: 1
12+
selector:
13+
matchLabels:
14+
{{- include "liqo.selectorLabels" $proxyConfig | nindent 6 }}
15+
template:
16+
metadata:
17+
{{- if .Values.proxy.pod.annotations }}
18+
annotations:
19+
{{- toYaml .Values.proxy.pod.annotations | nindent 8 }}
20+
{{- end }}
21+
labels:
22+
{{- include "liqo.labels" $proxyConfig | nindent 8 }}
23+
{{- if .Values.proxy.pod.labels }}
24+
{{- toYaml .Values.proxy.pod.labels | nindent 8 }}
25+
{{- end }}
26+
spec:
27+
securityContext:
28+
{{- include "liqo.podSecurityContext" . | nindent 8 }}
29+
containers:
30+
- image: {{ .Values.proxy.imageName }}
31+
imagePullPolicy: {{ .Values.pullPolicy }}
32+
name: {{ $proxyConfig.name }}
33+
securityContext:
34+
{{- include "liqo.containerSecurityContext" . | nindent 12 }}
35+
ports:
36+
- containerPort: {{ .Values.proxy.config.listeningPort }}
37+
resources:
38+
requests:
39+
cpu: 250m
40+
memory: 100M
41+
volumeMounts:
42+
- mountPath: /etc/envoy/envoy.yaml
43+
name: config-volume
44+
subPath: config
45+
volumes:
46+
- name: config-volume
47+
configMap:
48+
name: {{ include "liqo.prefixedName" $proxyConfig }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
{{- $proxyConfig := (merge (dict "name" "proxy" "module" "networking") .) -}}
3+
4+
apiVersion: v1
5+
kind: Service
6+
metadata:
7+
name: {{ include "liqo.prefixedName" $proxyConfig }}
8+
{{- if .Values.proxy.service.annotations }}
9+
annotations:
10+
{{- toYaml .Values.proxy.service.annotations | nindent 4 }}
11+
{{- end}}
12+
labels:
13+
{{- include "liqo.labels" $proxyConfig | nindent 4 }}
14+
spec:
15+
type: {{ .Values.proxy.service.type }}
16+
ports:
17+
- name: http
18+
port: {{ .Values.proxy.config.listeningPort }}
19+
targetPort: {{ .Values.proxy.config.listeningPort }}
20+
protocol: TCP
21+
selector:
22+
{{- include "liqo.selectorLabels" $proxyConfig | nindent 4 }}

deployments/liqo/values.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,23 @@ virtualKubelet:
223223
# -- virtual node extra labels
224224
labels: {}
225225

226+
proxy:
227+
pod:
228+
# -- proxy pod annotations
229+
annotations: {}
230+
# -- proxy pod labels
231+
labels: {}
232+
# -- proxy pod extra arguments
233+
extraArgs: []
234+
# -- proxy image repository
235+
imageName: "envoyproxy/envoy:v1.21.0"
236+
service:
237+
type: "ClusterIP"
238+
annotations: {}
239+
config:
240+
# -- port used by envoy proxy
241+
listeningPort: 8118
242+
226243
storage:
227244
# -- enable the liqo virtual storage class on the local cluster. You will be able to
228245
# offload your persistent volumes and other clusters will be able to schedule their

docs/pages/installation/chart_values.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ weight: 5
7373
| networkManager.pod.extraArgs | list | `[]` | networkManager pod extra arguments |
7474
| networkManager.pod.labels | object | `{}` | networkManager pod labels |
7575
| openshiftConfig.enable | bool | `false` | enable the OpenShift support |
76+
| proxy.config.listeningPort | int | `8118` | port used by envoy proxy |
77+
| proxy.imageName | string | `"envoyproxy/envoy:v1.21.0"` | proxy image repository |
78+
| proxy.pod.annotations | object | `{}` | proxy pod annotations |
79+
| proxy.pod.extraArgs | list | `[]` | proxy pod extra arguments |
80+
| proxy.pod.labels | object | `{}` | proxy pod labels |
81+
| proxy.service.annotations | object | `{}` | |
82+
| proxy.service.type | string | `"ClusterIP"` | |
7683
| pullPolicy | string | `"IfNotPresent"` | The pullPolicy for liqo pods |
7784
| route.imageName | string | `"liqo/liqonet"` | route image repository |
7885
| route.pod.annotations | object | `{}` | route pod annotations |

pkg/consts/labels.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const (
3636
NetworkManagerAppName = "network-manager"
3737

3838
// APIServerProxyAppName label value that denotes the name of the liqo-api-server-proxy deployment.
39-
APIServerProxyAppName = "api-server-proxy"
39+
APIServerProxyAppName = "proxy"
4040
// NatMappingResourceLabelKey is the constant representing
4141
// the key of the label assigned to all NatMapping resources.
4242
NatMappingResourceLabelKey = "net.liqo.io/natmapping"

pkg/liqoctl/common/cluster.go

Lines changed: 32 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ const (
6363

6464
proxyName = "liqo-proxy"
6565

66-
authPort = "https"
66+
authPort = "https"
67+
proxyPort = "http"
6768
)
6869

6970
var (
@@ -286,6 +287,25 @@ func (c *Cluster) Init(ctx context.Context) error {
286287
}
287288
s.Success("authentication endpoint correctly retrieved")
288289

290+
// Get proxy endpoint.
291+
s, _ = c.printer.Spinner.Start("retrieving proxy endpoint")
292+
selector, err = metav1.LabelSelectorAsSelector(&liqolabels.ProxyServiceLabelSelector)
293+
if err != nil {
294+
s.Fail(fmt.Sprintf("an error occurred while retrieving proxy endpoint: %v", err))
295+
return err
296+
}
297+
svc, err = liqogetters.GetServiceByLabel(ctx, c.locCtrlRunClient, c.namespace, selector)
298+
if err != nil {
299+
s.Fail(fmt.Sprintf("an error occurred while retrieving proxy endpoint: %v", err))
300+
return err
301+
}
302+
ipProxy, portProxy, err := liqogetters.RetrieveEndpointFromService(svc, corev1.ServiceTypeClusterIP, proxyPort)
303+
if err != nil {
304+
s.Fail(fmt.Sprintf("an error occurred while retrieving proxy endpoint: %v", err))
305+
return err
306+
}
307+
s.Success("proxy endpoint correctly retrieved")
308+
289309
// Set configuration
290310
c.clusterID = clusterID
291311
c.netConfig = netcfg
@@ -304,6 +324,11 @@ func (c *Cluster) Init(ctx context.Context) error {
304324
port: portAuth,
305325
}
306326

327+
c.proxyEP = &Endpoint{
328+
ip: ipProxy,
329+
port: portProxy,
330+
}
331+
307332
return nil
308333
}
309334

@@ -631,22 +656,6 @@ func (c *Cluster) StopPortForwardIPAM() {
631656
s.Success(fmt.Sprintf("IPAM service port-forward correctly stopped {%s}", c.PortForwardOpts.Ports[0]))
632657
}
633658

634-
// SetUpProxy configures the proxy deployment.
635-
func (c *Cluster) SetUpProxy(ctx context.Context) error {
636-
s, _ := c.printer.Spinner.Start(fmt.Sprintf("configuring proxy pod {%s} and service in namespace {%s}", proxyName, c.namespace))
637-
638-
ep, err := createProxyDeployment(ctx, c.locK8sClient, proxyName, c.namespace)
639-
if err != nil {
640-
s.Fail(fmt.Sprintf("an error occurred while setting up proxy {%s} in namespace {%s}: %v", proxyName, c.namespace, err))
641-
return err
642-
}
643-
s.Success(fmt.Sprintf("proxy {%s} correctly configured in namespace {%s}", proxyName, c.namespace))
644-
645-
c.proxyEP = ep
646-
647-
return nil
648-
}
649-
650659
// MapProxyIPForCluster maps the ClusterIP address of the local proxy on the local external CIDR as seen by the remote cluster.
651660
func (c *Cluster) MapProxyIPForCluster(ctx context.Context, ipamClient ipam.IpamClient, remoteCluster *discoveryv1alpha1.ClusterIdentity) error {
652661
clusterName := remoteCluster.ClusterName
@@ -670,36 +679,10 @@ func (c *Cluster) MapProxyIPForCluster(ctx context.Context, ipamClient ipam.Ipam
670679
// UnmapProxyIPForCluster unmaps the ClusterIP address of the local proxy on the local external CIDR as seen by the remote cluster.
671680
func (c *Cluster) UnmapProxyIPForCluster(ctx context.Context, ipamClient ipam.IpamClient, remoteCluster *discoveryv1alpha1.ClusterIdentity) error {
672681
clusterName := remoteCluster.ClusterName
673-
674-
// TODO: this logic will be moved on the Init function once
675-
// the creation of the proxy deployment and service will be
676-
// done at install time of liqo through the helm chart.
682+
ipToBeUnmapped := c.proxyEP.GetIP()
677683

678684
s, _ := c.printer.Spinner.Start(fmt.Sprintf("unmapping proxy ip for cluster {%s}", clusterName))
679685

680-
selector, err := metav1.LabelSelectorAsSelector(&liqolabels.ProxyServiceLabelSelector)
681-
if err != nil {
682-
s.Fail(fmt.Sprintf("an error occurred while retrieving proxy endpoint: %v", err))
683-
return err
684-
}
685-
svc, err := liqogetters.GetServiceByLabel(ctx, c.locCtrlRunClient, c.namespace, selector)
686-
if client.IgnoreNotFound(err) != nil {
687-
s.Fail(fmt.Sprintf("an error occurred while retrieving proxy endpoint: %v", err))
688-
return err
689-
}
690-
if k8serrors.IsNotFound(err) {
691-
s.Warning(fmt.Sprintf("service for proxy not found, unable to unmap proxy ip for cluster {%s}", clusterName))
692-
return nil
693-
}
694-
695-
ipAuth, _, err := liqogetters.RetrieveEndpointFromService(svc, corev1.ServiceTypeClusterIP, "http")
696-
if err != nil {
697-
s.Fail(fmt.Sprintf("an error occurred while retrieving proxy endpoint: %v", err))
698-
return err
699-
}
700-
701-
ipToBeUnmapped := ipAuth
702-
703686
if err := unmapServiceForCluster(ctx, ipamClient, ipToBeUnmapped, remoteCluster); err != nil {
704687
s.Fail(fmt.Sprintf("an error occurred while unmapping proxy address {%s} for cluster {%s}: %v", ipToBeUnmapped, clusterName, err))
705688
return err
@@ -713,19 +696,19 @@ func (c *Cluster) UnmapProxyIPForCluster(ctx context.Context, ipamClient ipam.Ip
713696
// MapAuthIPForCluster maps the ClusterIP address of the local auth service on the local external CIDR as seen by the remote cluster.
714697
func (c *Cluster) MapAuthIPForCluster(ctx context.Context, ipamClient ipam.IpamClient, remoteCluster *discoveryv1alpha1.ClusterIdentity) error {
715698
clusterName := remoteCluster.ClusterName
716-
ipToBeUnmapped := c.authEP.GetIP()
699+
ipToBeRemapped := c.authEP.GetIP()
717700

718-
s, _ := c.printer.Spinner.Start(fmt.Sprintf("mapping auth ip {%s} for cluster {%s}", ipToBeUnmapped, clusterName))
701+
s, _ := c.printer.Spinner.Start(fmt.Sprintf("mapping auth ip {%s} for cluster {%s}", ipToBeRemapped, clusterName))
719702

720-
ip, err := mapServiceForCluster(ctx, ipamClient, ipToBeUnmapped, remoteCluster)
703+
ip, err := mapServiceForCluster(ctx, ipamClient, ipToBeRemapped, remoteCluster)
721704
if err != nil {
722-
s.Fail(fmt.Sprintf("an error occurred while mapping auth address {%s} for cluster {%s}: %v", ipToBeUnmapped, clusterName, err))
705+
s.Fail(fmt.Sprintf("an error occurred while mapping auth address {%s} for cluster {%s}: %v", ipToBeRemapped, clusterName, err))
723706
return err
724707
}
725708

726709
c.authEP.SetRemappedIP(ip)
727710

728-
s.Success(fmt.Sprintf("auth address {%s} remapped to {%s} for remote cluster {%s}", ipToBeUnmapped, ip, clusterName))
711+
s.Success(fmt.Sprintf("auth address {%s} remapped to {%s} for remote cluster {%s}", ipToBeRemapped, ip, clusterName))
729712

730713
return nil
731714
}

0 commit comments

Comments
 (0)