### Bootstrap Infrastructure Setup Script Source: https://context7.com/richmo/apollo-operator-demo/llms.txt This bash script automates the initial cluster setup. It installs ArgoCD, creates the 'apollo-operator' namespace, applies a bootstrap ArgoCD Application using the app-of-apps pattern, tunes ArgoCD for faster reconciliation, and retrieves the initial admin password. Requires `kubectl` and `bash`. ```bash #!/usr/bin/env bash # Verify cluster context echo "Current context: $(kubectl config current-context)" read -rp "Press enter to continue" # Install ArgoCD kubectl create namespace argocd kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml kubectl rollout status -n argocd statefulset argocd-application-controller # Apply bootstrap configuration kubectl apply -f bootstrap.yaml # Tune ArgoCD for faster reconciliation kubectl patch -n argocd cm argocd-cm -p '{ "data": { "timeout.reconciliation": "5s", "timeout.reconciliation.jitter": "1s" }}' kubectl rollout restart -n argocd statefulset argocd-application-controller kubectl rollout status -n argocd statefulset argocd-application-controller # Retrieve admin password echo "ArgoCD Password: $(kubectl -n argocd get secrets/argocd-initial-admin-secret --template='{{.data.password}}' | base64 -d)" ``` -------------------------------- ### Install Apollo Operator using ArgoCD and Helm Source: https://context7.com/richmo/apollo-operator-demo/llms.txt An ArgoCD Application resource that deploys the Apollo Operator via its official Helm chart. It configures the operator with an API key secret and specifies a namespace for installation, while ignoring certain Kubernetes CRD differences to prevent sync issues. ```yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: operator namespace: argocd spec: project: default ignoreDifferences: - group: apiextensions.k8s.io kind: CustomResourceDefinition jsonPointers: - /spec/names/shortNames - /spec/names/categories jqPathExpressions: - .spec.versions[]?.additionalPrinterColumns source: chart: operator-chart repoURL: registry-1.docker.io/apollograph targetRevision: "1.0.0" helm: releaseName: apollo-operator valuesObject: apiKey: secretName: apollo-api-key destination: server: "https://kubernetes.default.svc" namespace: apollo-operator syncPolicy: automated: {} ``` -------------------------------- ### Access Apollo Router Sandbox via Port-Forward Source: https://context7.com/richmo/apollo-operator-demo/llms.txt This bash command sets up a local port-forward from your machine's port 4000 to the Apollo Router service (named 'retail') in the 'apollo-operator' namespace. This allows you to access the unified supergraph API and its GraphQL Sandbox from your local environment. Requires `kubectl`. ```bash kubectl -n apollo-operator port-forward service/retail 4000:80 # Access sandbox at http://localhost:4000 # Example query: # query GetProductWithReviews { # product(id: "1") { # id # name # description # reviews { # id # body # author # } # } # } ``` -------------------------------- ### Implement Apollo Federation v2 Reviews Subgraph with JavaScript Source: https://context7.com/richmo/apollo-operator-demo/llms.txt Builds a Federation v2 subgraph using Apollo Server and resolvers. It extends the Product type from another subgraph and provides review data. Requires `graphql`, `@apollo/subgraph`, and standard Node.js modules. ```javascript // subgraph.js import { parse } from "graphql"; import { buildSubgraphSchema } from "@apollo/subgraph"; import { resolvers } from "./resolvers.js"; import { readFileSync } from "fs"; import { dirname, resolve } from "path"; import { fileURLToPath } from "url"; const __dirname = dirname(fileURLToPath(import.meta.url)); const typeDefs = parse( readFileSync(resolve(__dirname, "schema.graphql"), "utf8") ); export const getReviewsSchema = () => buildSubgraphSchema([{ typeDefs, resolvers }]); // resolvers.js import { REVIEWS } from "./data.js"; export const getReviewsById = (reviewId) => REVIEWS.find((it) => it.id === reviewId); export const getReviewsByProductUpc = (productUpc) => REVIEWS.filter((it) => it.product.id === productUpc); export const resolvers = { Review: { __resolveReference: (ref) => getReviewsById(ref.id) }, Product: { reviews: (parent) => getReviewsByProductUpc(parent.id) } }; // server.js import { ApolloServer } from "@apollo/server"; import { startStandaloneServer } from "@apollo/server/standalone"; import { getReviewsSchema } from "./subgraph.js"; async function startServer() { const schema = getReviewsSchema(); const server = new ApolloServer({ schema, introspection: true, playground: true, }); const { url } = await startStandaloneServer(server, { listen: { port: process.env.PORT || 4000, host: "0.0.0.0" }, }); console.log(`🚀 Reviews subgraph ready at ${url}`); } startServer().catch((error) => { console.error("❌ Error starting server:", error); process.exit(1); }); ``` -------------------------------- ### ArgoCD Application for Products Subgraph Source: https://context7.com/richmo/apollo-operator-demo/llms.txt This ArgoCD Application resource deploys the Products subgraph. It synchronizes Kubernetes manifests from a specified path in a Git repository to the cluster. Dependencies include ArgoCD running in the cluster. ```yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: products namespace: argocd spec: project: default source: path: products repoURL: https://github.com/richmo/apollo-operator-demo destination: server: "https://kubernetes.default.svc" namespace: apollo-operator syncPolicy: automated: {} ``` -------------------------------- ### Apollo API Key Secret Creation Source: https://context7.com/richmo/apollo-operator-demo/llms.txt These bash commands create an API key for Apollo Studio using the Rover CLI and then store this key as a Kubernetes secret named 'apollo-api-key' in the 'apollo-operator' namespace. This secret is used by the Apollo Operator for authentication with Apollo Studio. Requires `rover` CLI and `kubectl`. ```bash # Create API key using Rover CLI rover api-key create summit-2025-operator-workshop operator operator-workshop-key # Store key in Kubernetes secret kubectl -n apollo-operator create secret generic \ --from-literal=APOLLO_KEY=service:my-graph:abc123xyz456 \ apollo-api-key ``` -------------------------------- ### Access ArgoCD Dashboard via Port-Forward Source: https://context7.com/richmo/apollo-operator-demo/llms.txt These bash commands retrieve the ArgoCD admin password and then set up a local port-forward from your machine's port 8080 to the ArgoCD server service in the 'argocd' namespace. This provides access to the ArgoCD web interface for managing deployments. Requires `kubectl`. ```bash # Get admin password kubectl -n argocd get secrets/argocd-initial-admin-secret \ --template='{{.data.password}}' | base64 -d # Port-forward to access UI kubectl -n argocd port-forward service/argocd-server 8080:80 # Login at http://localhost:8080 # Username: admin # Password: (from command above) ``` -------------------------------- ### ArgoCD Application for Reviews Subgraph Source: https://context7.com/richmo/apollo-operator-demo/llms.txt This ArgoCD Application resource deploys the Reviews subgraph. It synchronizes Kubernetes manifests from a specified path in a Git repository to the cluster. Dependencies include ArgoCD running in the cluster. ```yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: reviews namespace: argocd spec: project: default source: path: reviews repoURL: https://github.com/richmo/apollo-operator-demo directory: include: "*.yaml" destination: server: "https://kubernetes.default.svc" namespace: apollo-operator syncPolicy: automated: {} ``` -------------------------------- ### Deploy Reviews Subgraph Service to Kubernetes Source: https://context7.com/richmo/apollo-operator-demo/llms.txt Provides standard Kubernetes Service and Deployment manifests for the Reviews subgraph. The Service exposes the subgraph internally on port 80, and the Deployment defines the container image and port 4000 for the subgraph to run. ```yaml apiVersion: v1 kind: Service metadata: name: reviews namespace: apollo-operator spec: selector: app: reviews ports: - protocol: TCP port: 80 targetPort: 4000 --- apiVersion: apps/v1 kind: Deployment metadata: labels: app: reviews name: reviews namespace: apollo-operator spec: replicas: 1 selector: matchLabels: app: reviews template: metadata: labels: app: reviews spec: containers: - image: ghcr.io/richmo/reviews:latest name: reviews ports: - containerPort: 4000 ``` -------------------------------- ### ArgoCD Application for Supergraph Source: https://context7.com/richmo/apollo-operator-demo/llms.txt This ArgoCD Application resource deploys the Apollo Router and its schema composition configuration. It synchronizes Kubernetes manifests for the Supergraph and SupergraphSchema resources from a Git repository. Dependencies include ArgoCD running in the cluster. ```yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: retail-supergraph namespace: argocd spec: project: default source: path: retail-supergraph repoURL: https://github.com/richmo/apollo-operator-demo destination: server: "https://kubernetes.default.svc" namespace: apollo-operator syncPolicy: automated: {} ``` -------------------------------- ### Monitor Apollo Operator Activity Source: https://context7.com/richmo/apollo-operator-demo/llms.txt This bash command follows the logs of the Apollo Operator deployment in the 'apollo-operator' namespace. It is used for troubleshooting issues related to schema composition, subgraph registration, router deployment, and Apollo Studio synchronization. Requires `kubectl`. ```bash kubectl -n apollo-operator logs deployment/apollo-operator --follow # Expected output includes: # - Subgraph discovery events # - Schema composition results # - Router configuration updates # - Apollo Studio sync status ``` -------------------------------- ### Define Federation v2 Reviews Subgraph Schema with GraphQL Source: https://context7.com/richmo/apollo-operator-demo/llms.txt Defines Federation v2 types, including entity keys and field extensions for the Reviews subgraph. It extends the Product type from another subgraph using the `@link` directive and `@key` directive for entity identification. This schema enables distributed type ownership. ```graphql extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key"]) "A review of a given product by a specific user" type Review @key(fields: "id") { id: ID! body: String author: String @deprecated(reason: "Use the new `user` field") user: User product: Product } type Product @key(fields: "id") { id: ID! reviews: [Review!] } type User @key(fields: "id", resolvable: false) { id: ID! } ``` -------------------------------- ### Register Subgraph from OCI Image Source: https://context7.com/richmo/apollo-operator-demo/llms.txt The Subgraph resource registers a deployed Apollo Federation subgraph. Schema is extracted from an OCI container image, enabling schema versioning alongside application code. The 'domain' label facilitates automatic discovery by SupergraphSchema. ```yaml apiVersion: apollographql.com/v1alpha2 kind: Subgraph metadata: name: reviews labels: domain: retail namespace: apollo-operator spec: endpoint: http://reviews schema: ociImage: reference: ghcr.io/richmo/reviews:latest path: /app/schema.graphql ``` -------------------------------- ### Aggregate Subgraphs into Supergraph Schema Source: https://context7.com/richmo/apollo-operator-demo/llms.txt The SupergraphSchema resource configures how the Apollo Operator composes multiple subgraphs into a unified supergraph. It utilizes label selectors to discover subgraphs and references an Apollo Studio graph variant for schema registry integration. ```yaml apiVersion: apollographql.com/v1alpha2 kind: SupergraphSchema metadata: name: retail spec: selectors: - matchLabels: domain: retail graphRef: My-Graph-adszf@current ``` -------------------------------- ### Register Connector-based Subgraph with Inline SDL Source: https://context7.com/richmo/apollo-operator-demo/llms.txt This Subgraph resource registers a subgraph using Apollo Connectors for declarative data fetching from REST APIs. The schema is defined inline using SDL and incorporates Federation v2 and Connect directives, specifying an external source and HTTP endpoints. ```yaml apiVersion: apollographql.com/v1alpha2 kind: Subgraph metadata: name: products labels: domain: retail namespace: apollo-operator spec: endpoint: https://ecommerce.demo-api.apollo.dev/products schema: sdl: | extend schema @link( url: "https://specs.apollo.dev/federation/v2.10" import: ["@key"] ) @link( url: "https://specs.apollo.dev/connect/v0.1" import: ["@connect", "@source"] ) @source( name: "ecomm" http: { baseURL: "https://ecommerce.demo-api.apollo.dev/" } ) type Product @key(fields: "id") { id: ID! name: String description: String category: String } type Query { product(id: ID!): Product @connect( source: "ecomm" http: { GET: "/products/{$args.id}" } selection: "id name description category" entity: true ) ``` -------------------------------- ### Configure Apollo Router Deployment with Supergraph CRD Source: https://context7.com/richmo/apollo-operator-demo/llms.txt The Supergraph custom resource (CRD) defines and deploys an Apollo Router instance. It allows configuration of replica count, schema source, and router-specific settings like sandbox access and introspection. The podTemplate section allows specifying router version. ```yaml apiVersion: apollographql.com/v1alpha2 kind: Supergraph metadata: name: router-retail spec: replicas: 2 schema: resource: name: retail routerConfig: homepage: enabled: false sandbox: enabled: true supergraph: introspection: true podTemplate: routerVersion: 2.7.0 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.