infra: Recreate pods on infra deploys (#275)
## Motivation and Context In staging (and prod, for now) we pull the `:latest` mcp-registry image. But K8s won't actually change anything unless we recreate the pods. This change ensures the workflow goes from docker -> staging -> prod, and changes the annotation so that the pods are recreated each deploy. This ensures they actually pull the latest version. ## How Has This Been Tested? Deployed locally to minikube ## Breaking Changes None ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed
This commit is contained in:
parent
c733cedaf8
commit
d555acb65b
1 changed files with 60 additions and 47 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package k8s
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
v1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/apps/v1"
|
||||
corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/core/v1"
|
||||
metav1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/meta/v1"
|
||||
|
|
@ -11,6 +14,17 @@ import (
|
|||
"github.com/modelcontextprotocol/registry/deploy/infra/pkg/providers"
|
||||
)
|
||||
|
||||
// getGitCommitHash returns the current git commit hash
|
||||
func getGitCommitHash() string {
|
||||
cmd := exec.Command("git", "rev-parse", "HEAD")
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
// Fallback to a default value if git command fails
|
||||
return "unknown"
|
||||
}
|
||||
return strings.TrimSpace(string(output))
|
||||
}
|
||||
|
||||
// DeployMCPRegistry deploys the MCP Registry to the Kubernetes cluster
|
||||
func DeployMCPRegistry(ctx *pulumi.Context, cluster *providers.ProviderInfo, environment string) (*corev1.Service, error) {
|
||||
conf := config.New(ctx, "mcp-registry")
|
||||
|
|
@ -58,6 +72,10 @@ func DeployMCPRegistry(ctx *pulumi.Context, cluster *providers.ProviderInfo, env
|
|||
Labels: pulumi.StringMap{
|
||||
"app": pulumi.String("mcp-registry"),
|
||||
},
|
||||
Annotations: pulumi.StringMap{
|
||||
// Use git commit hash to trigger pod restarts when deploying new infra versions
|
||||
"registry.modelcontextprotocol.io/deployCommit": pulumi.String(getGitCommitHash()),
|
||||
},
|
||||
},
|
||||
Spec: &corev1.PodSpecArgs{
|
||||
Containers: corev1.ContainerArray{
|
||||
|
|
|
|||
Loading…
Reference in a new issue