Skip to content

Commit f2e392c

Browse files
author
Bob Furu
authored
Merge pull request #36738 from michaelryanpeter/OSDOCS-2211_OSDK-proxy-docs
2 parents e6b3496 + 416a831 commit f2e392c

File tree

5 files changed

+140
-0
lines changed

5 files changed

+140
-0
lines changed

modules/osdk-run-proxy.adoc

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * operators/operator_sdk/golang/osdk-golang-tutorial.adoc
4+
// * operators/operator_sdk/ansible/osdk-ansible-tutorial.adoc
5+
// * operators/operator_sdk/helm/osdk-helm-tutorial.adoc
6+
7+
ifeval::["{context}" == "osdk-golang-tutorial"]
8+
:golang:
9+
endif::[]
10+
ifeval::["{context}" == "osdk-ansible-tutorial"]
11+
:ansible:
12+
endif::[]
13+
ifeval::["{context}" == "osdk-helm-tutorial"]
14+
:helm:
15+
endif::[]
16+
17+
[id="osdk-run-proxy_{context}"]
18+
= Enabling proxy support
19+
20+
To support proxied clusters, your Operator must inspect the environment for the following standard proxy variables and pass the values to Operands:
21+
22+
* `HTTP_PROXY`
23+
* `HTTPS_PROXY`
24+
* `NO_PROXY`
25+
26+
[NOTE]
27+
====
28+
This tutorial uses `HTTP_PROXY` as an example environment variable.
29+
====
30+
31+
.Prerequisites
32+
* A cluster with cluster-wide egress proxy enabled.
33+
34+
.Procedure
35+
ifdef::golang[]
36+
. Add the `proxy.ReadProxyVarsFromEnv` helper function to the reconcile loop in the `controllers/memcached_controller.go` file and append the results to the Operand environments:
37+
+
38+
[source,golang]
39+
----
40+
...
41+
for i, container := range dep.Spec.Template.Spec.Containers {
42+
dep.Spec.Template.Spec.Containers[i].Env = append(container.Env, proxy.ReadProxyVarsFromEnv()...)
43+
}
44+
...
45+
----
46+
47+
endif::[]
48+
49+
ifdef::ansible[]
50+
. Add the environment variables to the deployment by updating the `roles/memcached/tasks/main.yml` file with the following:
51+
+
52+
[source,yaml]
53+
----
54+
...
55+
env:
56+
- name: HTTP_PROXY
57+
value: '{{ lookup("env", "HTTP_PROXY") | default("", True) }}'
58+
- name: http_proxy
59+
value: '{{ lookup("env", "HTTP_PROXY") | default("", True) }}'
60+
...
61+
----
62+
63+
endif::[]
64+
65+
ifdef::helm[]
66+
* Edit the `watches.yaml` file to include overrides based on an environment variable by adding the `overrideValues` field:
67+
+
68+
[source,yaml]
69+
----
70+
...
71+
- group: demo.example.com
72+
version: v1alpha1
73+
kind: Nginx
74+
chart: helm-charts/nginx
75+
overrideValues:
76+
proxy.http: $HTTP_PROXY
77+
...
78+
----
79+
80+
. Add the `proxy.http` value in the `helmcharts/nginx/values.yaml` file:
81+
+
82+
[source,yaml]
83+
----
84+
...
85+
proxy:
86+
http: ""
87+
https: ""
88+
no_proxy: ""
89+
----
90+
91+
. To make sure the chart template supports using the variables, edit the chart template in the `helm-charts/nginx/templates/deployment.yaml` file to contain the following:
92+
+
93+
[source,yaml]
94+
----
95+
containers:
96+
- name: {{ .Chart.Name }}
97+
securityContext:
98+
- toYaml {{ .Values.securityContext | nindent 12 }}
99+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
100+
imagePullPolicy: {{ .Values.image.pullPolicy }}
101+
env:
102+
- name: http_proxy
103+
value: "{{ .Values.proxy.http }}"
104+
----
105+
106+
endif::[]
107+
108+
. Set the environment variable on the Operator deployment by adding the following to the `config/manager/manager.yaml` file:
109+
+
110+
[source,yaml]
111+
----
112+
containers:
113+
- args:
114+
- --leader-elect
115+
- --leader-election-id=ansible-proxy-demo
116+
image: controller:latest
117+
name: manager
118+
env:
119+
- name: "HTTP_PROXY"
120+
value: "http_proxy_test"
121+
----
122+
123+
124+
ifeval::["{context}" == "osdk-golang-tutorial"]
125+
:!golang:
126+
endif::[]
127+
ifeval::["{context}" == "osdk-ansible-tutorial"]
128+
:!ansible:
129+
endif::[]
130+
ifeval::["{context}" == "osdk-helm-tutorial"]
131+
:!helm:
132+
endif::[]

operators/admin/olm-configuring-proxy-support.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ If a global proxy is configured on the {product-title} cluster, Operator Lifecyc
1111

1212
* xref:../../networking/enable-cluster-wide-proxy.adoc#enable-cluster-wide-proxy[Configuring the cluster-wide proxy]
1313
* xref:../../networking/configuring-a-custom-pki.adoc#configuring-a-custom-pki[Configuring a custom PKI] (custom CA certificate)
14+
* Developing Operators that support proxy settings for xref:../../operators/operator_sdk/golang/osdk-golang-tutorial.adoc#osdk-run-proxy_osdk-golang-tutorial[Go], xref:../../operators/operator_sdk/ansible/osdk-ansible-tutorial.adoc#osdk-run-proxy_osdk-ansible-tutorial[Ansible], and xref:../../operators/operator_sdk/helm/osdk-helm-tutorial.adoc#osdk-run-proxy_osdk-helm-tutorial[Helm]
15+
1416

1517
include::modules/olm-overriding-proxy-settings.adoc[leveloffset=+1]
1618
include::modules/olm-injecting-custom-ca.adoc[leveloffset=+1]

operators/operator_sdk/ansible/osdk-ansible-tutorial.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ include::modules/osdk-project-file.adoc[leveloffset=+2]
3030
include::modules/osdk-ansible-create-api.adoc[leveloffset=+1]
3131
include::modules/osdk-ansible-modify-manager.adoc[leveloffset=+1]
3232

33+
include::modules/osdk-run-proxy.adoc[leveloffset=+1]
3334
include::modules/osdk-run-operator.adoc[leveloffset=+1]
3435
include::modules/osdk-run-locally.adoc[leveloffset=+2]
3536
include::modules/osdk-run-deployment.adoc[leveloffset=+2]
@@ -46,3 +47,4 @@ include::modules/osdk-create-cr.adoc[leveloffset=+1]
4647
== Additional resources
4748

4849
- See xref:../../../operators/operator_sdk/ansible/osdk-ansible-project-layout.adoc#osdk-ansible-project-layout[Project layout for Ansible-based Operators] to learn about the directory structures created by the Operator SDK.
50+
- If a xref:../../../networking/enable-cluster-wide-proxy.adoc#enable-cluster-wide-proxy[cluster-wide egress proxy is configured], cluster administrators can xref:../../../operators/admin/olm-configuring-proxy-support.adoc#olm-configuring-proxy-support[override the proxy settings or inject a custom CA certificate] for specific Operators running on Operator Lifecycle Manager (OLM).

operators/operator_sdk/golang/osdk-golang-tutorial.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ include::modules/osdk-golang-controller-configs.adoc[leveloffset=+2]
3939
include::modules/osdk-golang-controller-reconcile-loop.adoc[leveloffset=+2]
4040
include::modules/osdk-golang-controller-rbac-markers.adoc[leveloffset=+2]
4141

42+
include::modules/osdk-run-proxy.adoc[leveloffset=+1]
4243
include::modules/osdk-run-operator.adoc[leveloffset=+1]
4344
include::modules/osdk-run-locally.adoc[leveloffset=+2]
4445
include::modules/osdk-run-deployment.adoc[leveloffset=+2]
@@ -55,3 +56,4 @@ include::modules/osdk-create-cr.adoc[leveloffset=+1]
5556
== Additional resources
5657

5758
- See xref:../../../operators/operator_sdk/golang/osdk-golang-project-layout.adoc#osdk-golang-project-layout[Project layout for Go-based Operators] to learn about the directory structures created by the Operator SDK.
59+
- If a xref:../../../networking/enable-cluster-wide-proxy.adoc#enable-cluster-wide-proxy[cluster-wide egress proxy is configured], cluster administrators can xref:../../../operators/admin/olm-configuring-proxy-support.adoc#olm-configuring-proxy-support[override the proxy settings or inject a custom CA certificate] for specific Operators running on Operator Lifecycle Manager (OLM).

operators/operator_sdk/helm/osdk-helm-tutorial.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ include::modules/osdk-helm-logic.adoc[leveloffset=+1]
3232
include::modules/osdk-helm-sample-chart.adoc[leveloffset=+2]
3333
include::modules/osdk-helm-modify-cr.adoc[leveloffset=+2]
3434

35+
include::modules/osdk-run-proxy.adoc[leveloffset=+1]
3536
include::modules/osdk-run-operator.adoc[leveloffset=+1]
3637
include::modules/osdk-run-locally.adoc[leveloffset=+2]
3738
include::modules/osdk-run-deployment.adoc[leveloffset=+2]
@@ -48,3 +49,4 @@ include::modules/osdk-create-cr.adoc[leveloffset=+1]
4849
== Additional resources
4950

5051
- See xref:../../../operators/operator_sdk/helm/osdk-helm-project-layout.adoc#osdk-helm-project-layout[Project layout for Helm-based Operators] to learn about the directory structures created by the Operator SDK.
52+
- If a xref:../../../networking/enable-cluster-wide-proxy.adoc#enable-cluster-wide-proxy[cluster-wide egress proxy is configured], cluster administrators can xref:../../../operators/admin/olm-configuring-proxy-support.adoc#olm-configuring-proxy-support[override the proxy settings or inject a custom CA certificate] for specific Operators running on Operator Lifecycle Manager (OLM).

0 commit comments

Comments
 (0)