Cuando se solicita Ingress, el navegador para el proxy es seguro. Sin embargo, si desea proteger la conexión de fondo, complete esta tarea.
Acerca de esta tarea
El mapa de configuración contiene las alteraciones temporales del archivo
server.xml. Estas alteraciones temporales habilitan la característica que es necesaria para SSL, configure el servidor
Liberty o el servicio
Liberty para utilizar los certificados que se han generado a partir del entramado.
Procedimiento
- Cree el archivo, libertyssl.xml, con los contenidos siguientes:
<?xml version="1.0" encoding="UTF -8"?>
<server>
<featureManager>
<feature>ssl-1.0</feature>
</featureManager>
<keyStore id="defaultKeyStore" location="/etc/wlp/config/keystore/key.jks"
password="${env.MB_KEYSTORE_PASSWORD}" />
<keyStore id="defaultTrustStore" location="/etc/wlp/config/truststore/trust.jks"
password="${env.MB_TRUSTSTORE_PASSWORD}" />
</server>
- Cree el mapa de configuración a partir del archivo que ha creado en el paso anterior:
kubectl create configmap liberty -ssl --from-file=libertyssl.xml
- Asegúrese de que existen los secretos de Kubernetes. Ejecute el mandato siguiente kubectl y busque los secretos de Kubernetes de mb -
truststore, mb - truststore, mb - keystore y mb - keystore - password en la lista siguiente:
kubectl get secrets
- Ejecute el mandato kubectl siguiente y busque el valor del mapa de configuración de liberty - ssl en la lista:
kubectl get configmap
- En el archivo deployment.yaml del servicio Liberty, cree el servicio siguiente:
apiVersion: v1
kind: Service
metadata:
name: liberty
labels:
name: liberty
spec:
selector:
name: liberty
ports:
- name: http
protocol: TCP
port: 9080
targetPort: 9080
- name: https
protocol: TCP
port: 9443
targetPort: 9443
type: NodePort
- En el archivo deployment.yaml del servicio Liberty, cree el archivo YAML de Ingress siguiente:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: liberty
labels:
name: liberty
annotations:
kubernetes.io/ingress.class: "nginx"
ingress.kubernetes.io/affinity: "cookie"
ingress.kubernetes.io/session-cookie-name: "route"
ingress.kubernetes.io/session-cookie-hash: "sha1"
ingress.kubernetes.io/rewrite-target: /
ingress.kubernetes.io/secure-backends: "true"
spec:
rules:
- host:
http:
paths:
- path: / liberty
backend:
serviceName: liberty
servicePort: 9443
- En el archivo deployment.yaml del servidor Liberty o servicio Liberty, cree los volúmenes en los cuales se montarán los secretos y el mapa de configuración. Utilice el fragmento de código siguiente sin modificarlo:
volumes:
- name: keystores
secret:
secretName: mb-keystore
- name: truststores
secret:
secretName: mb-truststore
- name: liberty-ssl
configMap:
name: liberty-ssl
items:
- key: libertyssl.xml
path: defaults/libertyssl.xml
- En el archivo deployment.yaml del servidor Liberty o servicio Liberty, monte los volúmenes creados. Utilice el fragmento de código siguiente sin modificarlo:
volumeMounts:
- name: keystores
mountPath: /etc/wlp/config/keystore
readOnly: true
- name: truststores
mountPath: /etc/wlp/config/truststore
readOnly: true
- name: liberty-ssl
mountPath: /config/configDropins
- En el archivo deployment.yaml de servidor Liberty o servicio Liberty, especifique las variables de entorno que hacen referencia a los secretos Kubernetes. Utilice el fragmento de código siguiente sin modificarlo:
env:
- name: MB_KEYSTORE_PASSWORD
valueFrom:
secretKeyRef:
name: mb-keystore-password
key: password
- name: MB_TRUSTSTORE_PASSWORD
valueFrom:
secretKeyRef:
name: mb-truststore-password
key: password
Ejemplo
El ejemplo siguiente es un archivo de despliegue de Liberty de ejemplo. La imagen de ejemplo utiliza los secretos de Kubernetes
mb-truststore,
mb-truststore-password,
mb-keystore y
mb-keystore-password; las variables de entorno
MB_KEYSTORE_PASSWORD y
MB_TRUSTSTORE_PASSWORD; y el mapa de configuración
liberty-ssl:
apiVersion: v1
kind: Service
metadata:
name: liberty
labels:
name: liberty
spec:
selector:
name: liberty
ports:
- name: http
protocol: TCP
port: 9080
targetPort: 9080
- name: https
protocol: TCP
port: 9443
targetPort: 9443
type: NodePort
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: liberty
spec:
replicas: 1
template:
metadata:
labels:
name: liberty
spec:
containers:
- name: liberty
image: master.cfc:8500/admin/liberty:latest
ports:
- containerPort: 9080
- containerPort: 9443
readinessProbe:
httpGet:
path: /
port: 9080
env:
- name: MB_KEYSTORE_PASSWORD
valueFrom:
secretKeyRef:
name: mb-keystore-password
key: password
- name: MB_TRUSTSTORE_PASSWORD
valueFrom:
secretKeyRef:
name: mb-truststore-password
key: password
volumeMounts:
- name: keystores
mountPath: /etc/wlp/config/keystore
readOnly: true
- name: truststores
mountPath: /etc/wlp/config/truststore
readOnly: true
- name: liberty-ssl
mountPath: /config/configDropins
readOnly: true
volumes:
- name: keystores
secret:
secretName: mb-keystore
- name: truststores
secret:
secretName: mb-truststore
- name: liberty-ssl
configMap:
name: liberty-ssl
items:
- key: libertyssl.xml
path: defaults/libertyssl.xml
imagePullSecrets:
- name: admin.registrykey
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: liberty
labels:
name: liberty
annotations:
kubernetes.io/ingress.class: "nginx"
ingress.kubernetes.io/affinity: "cookie"
ingress.kubernetes.io/session-cookie-name: "route"
ingress.kubernetes.io/session-cookie-hash: "sha1"
ingress.kubernetes.io/rewrite-target: /
ingress.kubernetes.io/secure-backends: "true"
spec:
rules:
- host:
http:
paths:
- path: / liberty
backend:
serviceName: liberty
servicePort: 9443
Qué hacer a continuación
Ejecute el mandato
kubectl para desplegar la aplicación. Acceda a la aplicación desde el URL siguiente:
https://<yourproxyip>/liberty