9.3. La validation du déploiement
Créer un nouveau projet:
$ oc new-project hello-worldDéployez une application hello world:
$ oc new-app -n hello-world --image=docker.io/openshift/hello-openshiftConfigurez un service NodePort pour que AWS ALB se connecte à:
$ cat << EOF | oc apply -f - apiVersion: v1 kind: Service metadata: name: hello-openshift-nodeport namespace: hello-world spec: ports: - port: 80 targetPort: 8080 protocol: TCP type: NodePort selector: deployment: hello-openshift EOFDéployer un AWS ALB à l’aide de l’opérateur AWS Load Balancer:
$ cat << EOF | oc apply -f - apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: hello-openshift-alb namespace: hello-world annotations: alb.ingress.kubernetes.io/scheme: internet-facing spec: ingressClassName: alb rules: - http: paths: - path: / pathType: Exact backend: service: name: hello-openshift-nodeport port: number: 80 EOFCurl le point de terminaison AWS ALB Ingress pour vérifier l’application hello world est accessible:
NoteAWS ALB provisioning prend quelques minutes. Lorsque vous recevez une erreur qui dit curl: (6) Ne peut pas résoudre l’hôte, s’il vous plaît attendre et essayer à nouveau.
$ INGRESS=$(oc -n hello-world get ingress hello-openshift-alb \ -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') $ curl "http://${INGRESS}"Exemple de sortie
Hello OpenShift!Déployez une AWS NLB pour votre application hello world:
$ cat << EOF | oc apply -f - apiVersion: v1 kind: Service metadata: name: hello-openshift-nlb namespace: hello-world annotations: service.beta.kubernetes.io/aws-load-balancer-type: external service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: instance service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing spec: ports: - port: 80 targetPort: 8080 protocol: TCP type: LoadBalancer selector: deployment: hello-openshift EOFEssayez le point de terminaison AWS NLB:
NoteLe provisionnement de la NLB prend quelques minutes. Lorsque vous recevez une erreur qui dit curl: (6) Ne peut pas résoudre l’hôte, s’il vous plaît attendre et essayer à nouveau.
$ NLB=$(oc -n hello-world get service hello-openshift-nlb \ -o jsonpath='{.status.loadBalancer.ingress[0].hostname}') $ curl "http://${NLB}"Exemple de sortie
Hello OpenShift!