Skip to content

Installation

CoSky can be used in two ways: as a library dependency integrated into your Spring Cloud application, or as a standalone REST API server for centralized management with a web dashboard. This page covers all installation methods.

Installation Methods Comparison

MethodProsConsBest For
Spring Cloud StarterZero extra infrastructure; integrates directly into your appNo management UI; each app connects to Redis independentlyMicroservices that self-register and self-configure
Standalone JARFull dashboard; RBAC; audit logsRequires a dedicated JVM processTeams wanting a management console without containers
DockerPortable; reproducible; easy to scaleRequires Docker runtimeContainerized environments, dev/test setups
KubernetesCloud-native; health probes; auto-restartRequires K8s clusterProduction cloud-native deployments
mermaid
%%{init: {'theme':'dark', 'themeVariables': {'primaryColor':'#2d333b','primaryBorderColor':'#6d5dfc','primaryTextColor':'#e6edf3','lineColor':'#8b949e','secondaryColor':'#161b22','tertiaryColor':'#161b22'}}}%%
flowchart TD
    START["Choose Installation Method"] --> Q1{"Need central<br>management UI?"}
    Q1 -->|No| LIB["Spring Cloud Starter<br>(library dependency)"]
    Q1 -->|Yes| Q2{"Container<br>platform?"}
    Q2 -->|Docker only| DOCKER["Docker deployment"]
    Q2 -->|Kubernetes| K8S["Kubernetes deployment"]
    Q2 -->|Neither| JAR["Standalone JAR<br>deployment"]

    LIB --> REDIS1[("Redis")]
    DOCKER --> REDIS2[("Redis")]
    K8S --> REDIS3[("Redis")]
    JAR --> REDIS4[("Redis")]

    style START fill:#2d333b,stroke:#6d5dfc,color:#e6edf3
    style Q1 fill:#2d333b,stroke:#6d5dfc,color:#e6edf3
    style Q2 fill:#2d333b,stroke:#6d5dfc,color:#e6edf3
    style LIB fill:#2d333b,stroke:#38a169,color:#e6edf3
    style DOCKER fill:#2d333b,stroke:#38a169,color:#e6edf3
    style K8S fill:#2d333b,stroke:#38a169,color:#e6edf3
    style JAR fill:#2d333b,stroke:#38a169,color:#e6edf3
    style REDIS1 fill:#2d333b,stroke:#dc382c,color:#e6edf3
    style REDIS2 fill:#2d333b,stroke:#dc382c,color:#e6edf3
    style REDIS3 fill:#2d333b,stroke:#dc382c,color:#e6edf3
    style REDIS4 fill:#2d333b,stroke:#dc382c,color:#e6edf3

As a Library Dependency

Add CoSky starters to your Spring Cloud application. These are published to Maven Central under me.ahoo.cosky.

Gradle (Kotlin DSL)

kotlin
val coskyVersion = "5.5.8"

dependencies {
    implementation("me.ahoo.cosky:spring-cloud-starter-cosky-config:${coskyVersion}")
    implementation("me.ahoo.cosky:spring-cloud-starter-cosky-discovery:${coskyVersion}")
    implementation("org.springframework.cloud:spring-cloud-starter-loadbalancer:3.0.3")
}

Maven

xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>demo</artifactId>
    <properties>
        <cosky.version>5.5.8</cosky.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>me.ahoo.cosky</groupId>
            <artifactId>spring-cloud-starter-cosky-config</artifactId>
            <version>${cosky.version}</version>
        </dependency>
        <dependency>
            <groupId>me.ahoo.cosky</groupId>
            <artifactId>spring-cloud-starter-cosky-discovery</artifactId>
            <version>${cosky.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-loadbalancer</artifactId>
            <version>3.0.3</version>
        </dependency>
    </dependencies>
</project>

Source: gradle.properties:14, README.md:46-87

Available Artifacts

ArtifactPurposeModule
spring-cloud-starter-cosky-configSpring Cloud config loading and real-time refreshcosky-spring-cloud-starter-config
spring-cloud-starter-cosky-discoverySpring Cloud service registration and discoverycosky-spring-cloud-starter-discovery
cosky-bomBill of Materials for dependency version managementcosky-bom

REST API Server Installation

The REST API server provides a management dashboard, REST endpoints, security (RBAC), and audit logging. It is optional -- your services work perfectly without it using just the library starters.

Option 1: Standalone JAR

Download the latest release and run directly:

bash
# Download cosky-server
wget https://github.com/Ahoo-Wang/cosky/releases/latest/download/cosky-server.tar

# Extract
tar -xvf cosky-server.tar
cd cosky-server

# Run with Redis connection
bin/cosky --server.port=8080 --spring.data.redis.url=redis://localhost:6379

On first startup, CoSky initializes the super user and prints the generated password to the console:

log
---------------- ****** CoSky -  init super user:[cosky] password:[6TrmOux4Oj] ****** ----------------

To reinitialize the password, set enforce-init-super-user: true in your configuration.

Source: README.md:119-127

Option 2: Docker

Quick deployment with Docker:

bash
# Pull the image
docker pull ahoowang/cosky:latest

# Run as a container
docker run --name cosky -d -p 8080:8080 \
  -e SPRING_DATA_REDIS_URL=redis://your-redis-host:6379 \
  ahoowang/cosky:latest

Docker Compose

For local development with Redis:

yaml
version: "3.8"
services:
  redis:
    image: redis:7
    ports:
      - "6379:6379"
  cosky:
    image: ahoowang/cosky:latest
    ports:
      - "8080:8080"
    environment:
      - SPRING_DATA_REDIS_URL=redis://redis:6379
    depends_on:
      - redis

Source: README.md:132-137

Option 3: Kubernetes

Deploy CoSky in your Kubernetes cluster. The project provides deployment manifests for both standalone Redis and Redis Cluster configurations.

Standalone Redis

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cosky
  labels:
    app: cosky
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cosky
  template:
    metadata:
      labels:
        app: cosky
    spec:
      containers:
        - name: cosky
          image: ahoowang/cosky:latest
          ports:
            - containerPort: 8080
              protocol: TCP
          env:
            - name: SPRING_DATA_REDIS_HOST
              value: redis-uri:6379
            - name: SPRING_DATA_REDIS_PASSWORD
              value: redis-pwd
            - name: TZ
              value: Asia/Shanghai
          startupProbe:
            httpGet:
              port: http
              path: /actuator/health
          readinessProbe:
            httpGet:
              port: http
              path: /actuator/health/readiness
          livenessProbe:
            httpGet:
              port: http
              path: /actuator/health/liveness
          resources:
            requests:
              cpu: 250m
              memory: 1024Mi
            limits:
              cpu: "1"
              memory: 1280Mi
          volumeMounts:
            - name: volume-localtime
              mountPath: /etc/localtime
      volumes:
        - name: volume-localtime
          hostPath:
            path: /etc/localtime

Source: k8s/deployment/cosky.yml

Redis Cluster

For production environments using Redis Cluster, reference secrets for node and password configuration:

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cosky
  labels:
    app: cosky
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cosky
  template:
    metadata:
      labels:
        app: cosky
    spec:
      containers:
        - name: cosky
          image: ahoowang/cosky:latest
          env:
            - name: SPRING_DATA_REDIS_CLUSTER_NODES
              valueFrom:
                secretKeyRef:
                  name: redis-secret
                  key: nodes
            - name: SPRING_DATA_REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: redis-secret
                  key: password
            - name: SPRING_DATA_REDIS_CLUSTER_MAX_REDIRECTS
              value: "3"
            - name: SPRING_DATA_REDIS_LETTUCE_CLUSTER_REFRESH_ADAPTIVE
              value: "true"
            - name: SPRING_DATA_REDIS_LETTUCE_CLUSTER_REFRESH_PERIOD
              value: 30s

Source: k8s/deployment/cosky-cluster.yml

Kubernetes Service

yaml
apiVersion: v1
kind: Service
metadata:
  name: cosky
  labels:
    app: cosky
spec:
  selector:
    app: cosky
  ports:
    - name: rest
      port: 80
      protocol: TCP
      targetPort: 8080

Source: k8s/deployment/cosky-service.yaml

Deployment Architecture

mermaid
%%{init: {'theme':'dark', 'themeVariables': {'primaryColor':'#2d333b','primaryBorderColor':'#6d5dfc','primaryTextColor':'#e6edf3','lineColor':'#8b949e','secondaryColor':'#161b22','tertiaryColor':'#161b22'}}}%%
graph TB
    subgraph K8s["Kubernetes Cluster"]
        style K8s fill:#161b22,stroke:#30363d,color:#e6edf3
        SVC["cosky Service<br>(ClusterIP:80)"]
        DEP["cosky Deployment<br>(1 replica)"]
        SVC --> DEP
    end

    subgraph Apps["Microservices"]
        style Apps fill:#161b22,stroke:#30363d,color:#e6edf3
        APP1["App 1<br>(config + discovery starters)"]
        APP2["App 2<br>(config + discovery starters)"]
        APP3["App 3<br>(config + discovery starters)"]
    end

    subgraph RedisInfra["Redis Infrastructure"]
        style RedisInfra fill:#161b22,stroke:#30363d,color:#e6edf3
        REDIS[("Redis<br>Standalone or Cluster")]
    end

    APP1 --> REDIS
    APP2 --> REDIS
    APP3 --> REDIS
    DEP --> REDIS

    style SVC fill:#2d333b,stroke:#6d5dfc,color:#e6edf3
    style DEP fill:#2d333b,stroke:#6d5dfc,color:#e6edf3
    style APP1 fill:#2d333b,stroke:#6d5dfc,color:#e6edf3
    style APP2 fill:#2d333b,stroke:#6d5dfc,color:#e6edf3
    style APP3 fill:#2d333b,stroke:#6d5dfc,color:#e6edf3
    style REDIS fill:#2d333b,stroke:#dc382c,color:#e6edf3

Configuration Reference

Key configuration properties for CoSky:

PropertyDefaultDescriptionSource
spring.data.redis.url(required)Redis connection URL (standalone)bootstrap.yaml
spring.data.redis.cluster.nodes(required for cluster)Redis cluster node addressescosky-cluster.yml:23
spring.data.redis.passwordRedis passwordcosky.yml:23
spring.cloud.cosky.namespacecosky-{default}Isolation namespace for services and configsCoSkyProperties.kt:30
spring.cloud.cosky.config.enabledtrueEnable config loading from RedisCoSkyConfigProperties.kt:26
spring.cloud.cosky.config.config-id${spring.application.name}.yamlConfig file ID to loadCoSkyConfigAutoConfiguration.kt:48
spring.cloud.cosky.config.file-extensionyamlDefault file extensionCoSkyConfigProperties.kt:27
spring.cloud.cosky.config.timeout2sTimeout for config loadingCoSkyConfigProperties.kt:28
spring.cloud.cosky.discovery.enabledtrueEnable service discoveryCoSkyDiscoveryProperties.kt:26
spring.cloud.cosky.discovery.timeout2sTimeout for discovery operationsCoSkyDiscoveryProperties.kt:28
spring.cloud.service-registry.auto-registration.enabledtrueAuto-register service on startupbootstrap.yaml:9
cosky.security.enabledtrueEnable security on REST API serverapplication.yaml:16
cosky.security.enforce-init-super-userfalseReinitialize super user passwordapplication.yaml:19

Instance Lifecycle Properties

When using the discovery starter, service instances have configurable TTL and heartbeat settings:

PropertyDefaultDescriptionSource
Instance TTL60sHow long an instance lives before being considered expiredRegistryProperties.kt:26
Renew period10sHow often the instance sends a heartbeat to renew its TTLRenewProperties.kt:28
Renew initial delay1sDelay before the first heartbeat after registrationRenewProperties.kt:25
mermaid
%%{init: {'theme':'dark', 'themeVariables': {'primaryColor':'#2d333b','primaryBorderColor':'#6d5dfc','primaryTextColor':'#e6edf3','lineColor':'#8b949e','secondaryColor':'#161b22','tertiaryColor':'#161b22'}}}%%
sequenceDiagram
    autonumber
    participant App as Application
    participant Registry as ServiceRegistry
    participant Renew as RenewInstanceService
    participant Redis as Redis

    App->>Registry: register(instance)
    Registry->>Redis: Lua script: register instance
    Redis-->>Registry: OK

    Note over Renew,Redis: Heartbeat loop starts after 1s initial delay

    loop Every 10 seconds
        Renew->>Redis: renew(instance) - extend TTL
        Redis-->>Renew: OK
    end

    Note over App,Redis: On graceful shutdown
    App->>Registry: deregister(instance)
    Registry->>Redis: remove instance data
    Redis-->>Registry: OK

    Note over Redis: If heartbeat stops, instance expires after 60s TTL

REST API Server Bootstrap Configuration

The REST API server uses the following bootstrap configuration:

yaml
spring:
  application:
    name: ${service.name:cosky-rest-api}
  cloud:
    cosky:
      namespace: ${cosky.namespace:cosky-{system}}
      config:
        config-id: ${spring.application.name}.yaml
    service-registry:
      auto-registration:
        enabled: ${cosky.auto-registry:true}

Source: cosky-rest-api/src/dist/config/bootstrap.yaml

Accessing the Dashboard

Once the REST API server is running, access the web-based management interface at:

http://localhost:8080

The dashboard provides:

  • Real-time service monitoring and management
  • Configuration management with version control and rollback
  • Namespace isolation and management
  • Role-based access control (RBAC)
  • Audit logging for compliance
  • Service topology visualization
  • Import/export functionality (including Nacos migration)

Source: README.md:206-219

References

Released under the Apache License 2.0.