You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于deployment.yml将微服务生态部署至IBM Cloud Kubernetes

Got it, let's walk through getting your microservices ecosystem deployed to IBM Cloud step by step. Since you already have your Dockerized services and Kubernetes manifests (deployment.yml + service.yml), most of the heavy lifting is already done—we just need to adapt them for IBM Cloud's Kubernetes Service (IKS) and handle a few cloud-specific steps.

完整部署流程:将微服务生态部署至IBM Cloud Services

1. 前期准备工作

  • First, make sure you have all the necessary tools installed:
    • ibmcloud CLI: For interacting with IBM Cloud
    • kubectl: You’re already using this—just double-check its version is compatible with your IKS cluster (run ibmcloud ks versions to see supported versions)
    • Docker: To build and push images to IBM Cloud’s container registry
  • Log in to your IBM Cloud account:
    ibmcloud login
    
    If you’re using an enterprise account, add the --sso flag: ibmcloud login --sso

2. Create/Select an IBM Cloud Kubernetes Service (IKS) Cluster

  • If you don’t have a cluster yet, spin one up (this takes ~10-15 minutes):
    ibmcloud ks cluster create classic --name your-cluster-name --zone your-preferred-zone --machine-type b3c.4x16
    
    Swap classic for vpc-gen2 if you want a VPC-based cluster, and adjust the machine type based on your service resource needs.
  • Once the cluster is ready, configure kubectl to connect to it:
    ibmcloud ks cluster config --cluster your-cluster-name
    
    Verify the connection works:
    kubectl get nodes
    
    You should see a list of your cluster’s nodes if everything’s set up correctly.

3. Push Docker Images to IBM Cloud Container Registry (ICR)

Your local Docker images need to live in IBM Cloud’s registry so IKS can pull them:

  • Create a namespace to organize your images:
    ibmcloud cr namespace-add your-namespace-name
    
  • Log in to the container registry:
    ibmcloud cr login
    
  • Tag your local image with the ICR format: REGISTRY_URL/NAMESPACE/IMAGE_NAME:TAG (get your registry URL via ibmcloud cr info, e.g., us.icr.io):
    docker tag your-local-image:v1 us.icr.io/your-namespace/your-service-image:v1
    
  • Push the image to ICR:
    docker push us.icr.io/your-namespace/your-service-image:v1
    
  • Confirm the image was uploaded successfully:
    ibmcloud cr image-list
    

4. Adjust Your Kubernetes Manifests

You’ll need to update your deployment.yml to pull images from ICR instead of your local Docker:

  • Find the spec.template.spec.containers[0].image field and replace your local image name with the full ICR image path you just pushed, like:
    image: us.icr.io/your-namespace/your-service-image:v1
    
  • Optional: If your services need persistent storage, secrets, or config maps, IBM Cloud offers managed services like Object Storage and Secrets Manager—you can define corresponding Kubernetes resources (e.g., PersistentVolumeClaim, Secret) to integrate these.

5. Deploy Your Microservices to IKS

This part is almost identical to your Minikube workflow:

  • Deploy your Deployment first:
    kubectl create -f deployment.yml
    
  • Then deploy your Service:
    kubectl create -f service.yml
    
  • Verify everything’s running:
    # Check pod status
    kubectl get pods
    # Check service status
    kubectl get services
    

6. Expose Services to the Public Internet (If Needed)

IBM Cloud offers two main ways to make your services externally accessible:

Option 1: Use a LoadBalancer Service

If your service.yml already defines a LoadBalancer type, IKS will automatically provision a public IP. Run kubectl get services and look for the EXTERNAL-IP field—use that IP to access your service.

Option 2: Use IBM Cloud Ingress (For Complex Routing)

If you need to route multiple services under a single domain, set up an Ingress:

  • Enable the Ingress add-on for your cluster:
    ibmcloud ks cluster addon enable ingress --cluster your-cluster-name
    
  • Create an ingress.yml file (example below):
    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: your-microservices-ingress
      annotations:
        kubernetes.io/ingress.class: "public-iks-k8s-nginx"
    spec:
      rules:
      - host: your-custom-domain.com # Or use IBM's default provided domain
        http:
          paths:
          - path: /auth-service
            pathType: Prefix
            backend:
              service:
                name: auth-service
                port:
                  number: 8080
          - path: /payment-service
            pathType: Prefix
            backend:
              service:
                name: payment-service
                port:
                  number: 8080
    
  • Deploy the Ingress:
    kubectl create -f ingress.yml
    
  • Get the public IP for your Ingress:
    kubectl get ingress
    

7. Monitor & Maintain Your Deployment

  • Use built-in IBM Cloud tools like Monitoring and Logs to keep an eye on your services, or use basic kubectl commands for quick checks:
    # View pod logs
    kubectl logs your-pod-name
    # Check cluster events for issues
    kubectl get events
    
  • To update a service later, just push a new image to ICR and roll out the update:
    kubectl set image deployment/your-deployment-name your-container-name=us.icr.io/your-namespace/your-service-image:v2
    

内容的提问来源于stack exchange,提问作者branko terzic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:12:19