为你的Ingress开启HTTPS支持, 使应用更加安全。Ingress支持HTTPS配置比较简单,这里使用私用证书进行配置,浏览器中会提示not secure
,需要到服务商买权威的CA证书。
创建证书
1 2 3 4
| $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout dex.key -out dex.crt -subj "/CN=dex.sso/O=dex.sso"
$ cat dex.key | base64 $ cat dex.crt | base64
|
配置Secret
1 2 3 4 5 6 7 8 9
| apiVersion: v1 data: tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN4RENDQWF3Q0NRRENzeHpHVTI5UFl6QU5CZ2txaGtpRzl3MEJBUXNGQURBa01SQXdEZ1lEVlFRRERBZGsKWlhndWMzTnZNUkF3RGdZRFZRUUtEQWRrWlhndWMzTnZNQjRYRFRFNE1EZ3dNakEzTkRFek5sb1hEVEU1TURndwpNakEzTkRFek5sb3dKREVRTUE0R0ExVUVBd3dIWkdWNExuTnpiekVRTUE0R0ExVUVDZ3dIWkdWNExuTnpiekNDCkFTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTDJIeDBIQytDY3Q4TjhJNDVnRk1yNXYKV1d2SUZIY1hSTDRLeUc5dW91MlRZYVhNNHRSSjU2VGtXSzhLSUFnd1RnUkFSUnJhTjFuMzZuaGFpM0xOYWxRZgpYTWhLMUo5cXI3bklLLzlvYjdYU1UxTzlOR2NSeU1ldkVTcGJ2bmh4dFkzNnVuR3hwT3hidjFsM25Oa1NkRXYyCmN6bGFWd1U1VGwwTlZsTlNkcjZ1YmRYYS85MXhOUnJDZkFwNjcydDMyaVZNMXhyNkNESW9qOHVjL3AxQmpjYkcKTDROckcwNTZBWDRBREVYWGRrMEJISzM4d29yOENpcTFMSUhNVnpwQXJhRW1FRUxSUU9SbU1wY1htRWZiNjUzcQo3RmNPejVpRjVkVVZVVzN3TXJZSjUzUzB6ZjJZc2FlQ01pRzZzMUM5Znl0QnpwNHBzRXQreWpZcEhZUGlBUl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NkUwOWNuZVNnb0NpZ2svbk1uYTYrQURON2YvZ0doSFZ6CkUwd0V6bnJlSVhlV3dwbmVOZTJMaUsvWjRELzZQU3JvZEo0QUVzRlZrTzZCS21JWGlXL25NaGJ0WG1uUFovZmEKY2hYWkxocnAwNzBvMlZxMWVLdEVBVGRrZ2x2N1RUNGQwSmZZUnQ1dnBpTWFZWm9hK2laVkVQWWhBb0dBSHVGUQpOM1hMQy9TbG5iVUZZYzN3cHY1S2hPN0JlMmxWQnNqV1gycmlVSW9RUE1hb0hBU0xhRWpjcDRKdnBiRW5ickpTCko1U2lDMDFNUlcrc1FuNVplWTdBLzBOdnk3MnBOdnJTRk1USVNySUxXR3FTUWdzaWE3MnNHSXBpYW9SbmZycHQKZkNEekFSYXVYd0c4OEM3Yy9wLzNCNEIvTGdZUWFxODY5R29lTGJFQ2dZQVB5NU1heXVTRUFEaTdyZHVJcVArZgp4amw5elhwMGpZa2RtOCtmNVhhdGlIaFl6STBzaHdsZHBXcU85R1NoR2VMVi9Md2d1bVFhQlRCa3Bta0JSOFlGCkQzbmhCQ0hjaDVIeEd0UkVzWnlRUjJtNXhhRGhVL2NYc3ZFVjBBcmRUeVl3S0VlTStlSnVXYTl1THdQM2VKeEMKbFFXSXNUbm9EQUpzWUE4NFJST2dMdz09Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K kind: Secret metadata: name: sso-secret namespace: sso type: Opaque
|
配置Ingress
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| apiVersion: extensions/v1beta1 kind: Ingress metadata: name: dex namespace: sso spec: tls: - secretName: sso-secret rules: - host: dex.sso http: paths: - backend: serviceName: dex servicePort: 80 path: /
|
Okay,配置完成。