9.3. La validation du déploiement


  1. Créer un nouveau projet:

    $ oc new-project hello-world
    Copy to Clipboard Toggle word wrap
  2. Déployez une application hello world:

    $ oc new-app -n hello-world --image=docker.io/openshift/hello-openshift
    Copy to Clipboard Toggle word wrap
  3. Configurez 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
    EOF
    Copy to Clipboard Toggle word wrap
  4. Dé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
    EOF
    Copy to Clipboard Toggle word wrap
  5. Curl le point de terminaison AWS ALB Ingress pour vérifier l’application hello world est accessible:

    Note

    AWS 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}"
    Copy to Clipboard Toggle word wrap

    Exemple de sortie

    Hello OpenShift!
    Copy to Clipboard Toggle word wrap

  6. 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
    EOF
    Copy to Clipboard Toggle word wrap
  7. Essayez le point de terminaison AWS NLB:

    Note

    Le 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}"
    Copy to Clipboard Toggle word wrap

    Exemple de sortie

    Hello OpenShift!
    Copy to Clipboard Toggle word wrap

Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat