Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
In diesem Dokument wird gezeigt, wie Spring Cloud Config in einem Kf-Cluster bereitgestellt wird.
Mit Spring Cloud Config können Sie Anwendungscode aus der Laufzeitkonfiguration entkoppeln.
Der Spring Cloud Config-Konfigurationsserver kann Konfigurationsdateien aus Git-Repositories, dem lokalen Dateisystem, den HashiCorp Vault-Servern oder Cloud Foundry CredHub lesen.
Sobald der Konfigurationsserver die Konfiguration gelesen hat, kann diese Konfiguration als YAML, mit Java-Attributen oder JSON über HTTP formatiert und bereitgestellt werden.
Hinweis
Sie benötigen einen Cluster bei installiertem Kf und Zugriff auf die Kf-Befehlszeile.
Darüber hinaus benötigen Sie folgende Software:
git: Git ist zum Klonen eines Repositorys erforderlich.
Spring Cloud Config-Konfigurationsserver herunterladen
So laden Sie die Konfigurationsserverquelle herunter:
Öffnen Sie ein Terminalfenster.
Klonen Sie die Quelle für den Konfigurationsserver:
gitclone--depth1"https://github.com/google/kf"
Konfigurationsserver konfigurieren und bereitstellen
So aktualisieren Sie die Einstellungen für die Instanz:
Ändern Sie das Verzeichnis in spring-cloud-config-server:
cdkf/spring-cloud-config-server
Öffnen Sie manifest.yaml.
Ändern Sie die Umgebungsvariable GIT_URI in den URI Ihres Git-Konfigurationsservers.
Ändern Sie optional den Namen der Anwendung im Manifest.
Stellen Sie den Konfigurationsserver ohne externe Route bereit. Wenn Sie den Namen der Anwendung im Manifest geändert haben, aktualisieren Sie ihn hier:
kfpush--no-routespring-cloud-config
Anwendungen an den Konfigurationsserver binden
Sie können einen vom Nutzer bereitgestellten Dienst erstellen, um den bereitgestellten Konfigurationsserver an andere Kf-Anwendungen im selben Cluster oder Namespace zu binden.
Wie Sie die Anwendungen konfigurieren, hängt von der verwendeten Bibliothek ab:
Erstellen Sie einen vom Nutzer bereitgestellten Dienst mit dem Namen config-server. Dieser Schritt muss nur einmal pro Konfigurationsserver durchgeführt werden:
Dadurch wird ein Eintrag in der Umgebungsvariablen VCAP_SERVICES für den Konfigurationsserver erstellt.
Andere Apps
Anwendungen, die eine direkte Verbindung zu einem Spring Cloud Config-Konfigurationsserver herstellen können, sollten so konfiguriert werden, dass über den internen Cluster-URI darauf zugegriffen wird:
http://spring-cloud-config
Für Spring-Anwendungen, die die Spring Cloud Config-Clientbibliothek verwenden, können Sie das Attribut spring.cloud.config.uri an der entsprechenden Stelle für Ihre Anwendung festlegen. Dies ist normalerweise eine application.properties- oder application.yaml-Datei.
Informationen zu anderen Frameworks finden Sie in den Referenzinformationen der Bibliothek.
Konfigurationsserver löschen
So entfernen Sie einen Konfigurationsserver:
Entfernen Sie alle Bindungen zum Konfigurationsserver. Führen Sie dazu für jede gebundene Anwendung die folgenden Befehle aus:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-31 (UTC)."],[],[],null,["# Deploy Spring Cloud Config\n\nThis document shows how to deploy Spring Cloud Config in a Kf cluster.\n\n[Spring Cloud Config](https://cloud.spring.io/spring-cloud-config/reference/html/)\nprovides a way to decouple application code from its runtime configuration.\nThe Spring Cloud Config configuration server can read configuration files from Git\nrepositories, the local filesystem, [HashiCorp Vault servers](https://www.vaultproject.io/),\nor [Cloud Foundry CredHub](https://docs.cloudfoundry.org/credhub/).\nOnce the configuration server has read the configuration, it can format and serve\nthat configuration as YAML, [Java Properties](https://docs.oracle.com/cd/E23095_01/Platform.93/ATGProgGuide/html/s0204propertiesfileformat01.html),\nor JSON over HTTP.\n\nBefore you begin\n----------------\n\nYou will need a cluster with Kf installed and access\nto the Kf CLI.\n\nAdditionally, you will need the following software:\n\n- **`git`**: Git is required to clone a repository.\n\nDownload the Spring Cloud Config configuration server\n-----------------------------------------------------\n\nTo download the configuration server source:\n\n1. Open a terminal.\n2. Clone the source for the configuration server:\n\n git clone --depth 1 \"https://github.com/google/kf\"\n\nConfigure and deploy a configuration server\n-------------------------------------------\n\nTo update the settings for the instance:\n\n1. Change directory to `spring-cloud-config-server`:\n\n cd kf/spring-cloud-config-server\n\n2. Open `manifest.yaml`.\n\n3. Change the `GIT_URI` environment variable to the URI of your Git configuration server.\n\n4. Optionally, change the name of the application in the manifest.\n\n5. Optionally, [configure additional properties or alternative property sources](https://cloud.spring.io/spring-cloud-config/reference/html/#_environment_repository)\n by editing `src/main/resources/application.properties`.\n\n6. Deploy the configuration server without an external route. If you changed\n the name of the application in the manifest, update it here:\n\n kf push --no-route \u003cvar translate=\"no\"\u003espring-cloud-config\u003c/var\u003e\n\n| **Note:** The default configuration is not production ready. The `README.md` file contains additional steps to take if you want to deploy the application to production.\n\nBind applications to the configuration server\n---------------------------------------------\n\nYou can create a [user provided service](/migrate/kf/docs/2.11/concepts/user-provided-services)\nto bind the deployed configuration server to other Kf\napplications in the same cluster or namespace.\n\nHow you configure them will depend on the library you use: \n\n### PCF applications\n\nExisting PCF applications that use [Pivotal's Spring Cloud Services client library](https://github.com/pivotal-cf/spring-cloud-services-starters)\ncan be bound using the following method:\n\n1. Create a user provided service named \u003cvar translate=\"no\"\u003econfig-server\u003c/var\u003e. This step\n only has to be done once per configuration server:\n\n kf cups \u003cvar translate=\"no\"\u003econfig-server\u003c/var\u003e -p '{\"uri\":\"http://\u003cvar translate=\"no\"\u003espring-cloud-config\u003c/var\u003e\"}' -t configuration\n\n | **Note:** If you want to use a configuration server in a different space, change the URI [to include the space](/migrate/kf/docs/2.11/concepts/service-discovery#how_to_use_service_discovery_with).\n2. For each application that needs get credentials, run:\n\n kf bind-service \u003cvar translate=\"no\"\u003eapplication-name\u003c/var\u003e \u003cvar translate=\"no\"\u003econfig-server\u003c/var\u003e\n kf restart \u003cvar translate=\"no\"\u003eapplication-name\u003c/var\u003e\n\n This will create an entry into the `VCAP_SERVICES` environment variable for\n the configuration server.\n\n### Other applications\n\nApplications that can connect directly to a Spring Cloud Config configuration\nserver should be configured to access it using its cluster internal URI: \n\n http://\u003cvar translate=\"no\"\u003espring-cloud-config\u003c/var\u003e\n\n| **Note:** If you want to use a configuration server in a different space, change the URI [to include the space name](/migrate/kf/docs/2.11/concepts/service-discovery#how_to_use_service_discovery_with).\n\n- For Spring applications that use the [Spring Cloud Config client library](https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_client.html) can set the `spring.cloud.config.uri` property in the appropriate location for your application. This is usually an `application.properties` or `application.yaml` file.\n- For other frameworks, see your library's reference information.\n\nDelete the configuration server\n-------------------------------\n\nTo remove a configuration server:\n\n1. Remove all bindings to the configuration server running the following commands for each bound application:\n\n kf unbind-service \u003cvar translate=\"no\"\u003eapplication-name\u003c/var\u003e \u003cvar translate=\"no\"\u003econfig-server\u003c/var\u003e\n kf restart \u003cvar translate=\"no\"\u003eapplication-name\u003c/var\u003e\n\n2. Remove the service entry for the configuration server:\n\n kf delete-service \u003cvar translate=\"no\"\u003econfig-server\u003c/var\u003e\n\n3. Delete the configuration server application:\n\n kf delete \u003cvar translate=\"no\"\u003espring-cloud-config\u003c/var\u003e\n\nWhat's next\n-----------\n\n- Read more about the [types of configuration sources](https://cloud.spring.io/spring-cloud-config/reference/html/#_environment_repository) Spring Cloud Config supports.\n- Learn about [the structure of the `VCAP_SERVICES` environment variable](/migrate/kf/docs/2.11/how-to/app-runtime#vcapservices) to understand how it can be used for service discovery."]]