diff --git a/controllers/ipfs/config_ipfs.sh b/controllers/ipfs/config_ipfs.sh index 91795028..3628c663 100644 --- a/controllers/ipfs/config_ipfs.sh +++ b/controllers/ipfs/config_ipfs.sh @@ -4,3 +4,9 @@ set -e ipfs config Addresses.API /ip4/$IPFS_API_HOST/tcp/$IPFS_API_PORT ipfs config Addresses.Gateway /ip4/$IPFS_GATEWAY_HOST/tcp/$IPFS_GATEWAY_PORT + +export IFS=";" +for profile in $IPFS_PROFILES; do + ipfs config profile apply $profile + echo "$profile profile has been applied" +done diff --git a/controllers/ipfs/peer_controller.go b/controllers/ipfs/peer_controller.go index cf01a622..5068fd35 100644 --- a/controllers/ipfs/peer_controller.go +++ b/controllers/ipfs/peer_controller.go @@ -29,11 +29,11 @@ type PeerReconciler struct { var ( //go:embed init_ipfs_config.sh - initIPFSConfig string + initIPFSConfigScript string //go:embed copy_swarm_key.sh - copySwarmKey string + copySwarmKeyScript string //go:embed config_ipfs.sh - configIPFS string + configIPFSScript string ) // +kubebuilder:rbac:groups=ipfs.kotal.io,resources=peers,verbs=get;list;watch;create;update;patch;delete @@ -192,9 +192,9 @@ func (r *PeerReconciler) specConfigmap(peer *ipfsv1alpha1.Peer, config *corev1.C if config.Data == nil { config.Data = make(map[string]string) } - config.Data["init_ipfs_config.sh"] = initIPFSConfig - config.Data["copy_swarm_key.sh"] = copySwarmKey - config.Data["config_ipfs.sh"] = configIPFS + config.Data["init_ipfs_config.sh"] = initIPFSConfigScript + config.Data["copy_swarm_key.sh"] = copySwarmKeyScript + config.Data["config_ipfs.sh"] = configIPFSScript } // reconcilePVC reconciles ipfs peer persistent volume claim @@ -376,6 +376,11 @@ func (r *PeerReconciler) specStatefulSet(peer *ipfsv1alpha1.Peer, sts *appsv1.St VolumeMounts: volumeMounts, }) + // init ipfs config + profiles := []string{} + for _, profile := range peer.Spec.Profiles { + profiles = append(profiles, string(profile)) + } // config ipfs initContainers = append(initContainers, corev1.Container{ Name: "config-ipfs", @@ -401,6 +406,10 @@ func (r *PeerReconciler) specStatefulSet(peer *ipfsv1alpha1.Peer, sts *appsv1.St Name: EnvIPFSGatewayHost, Value: peer.Spec.GatewayHost, }, + { + Name: EnvIPFSProfiles, + Value: strings.Join(profiles, ";"), + }, }, Command: []string{"/bin/sh"}, Args: []string{ diff --git a/controllers/ipfs/types.go b/controllers/ipfs/types.go index a3908092..0f79f09c 100644 --- a/controllers/ipfs/types.go +++ b/controllers/ipfs/types.go @@ -15,6 +15,8 @@ const ( EnvIPFSGatewayHost = "IPFS_GATEWAY_HOST" // EnvIPFSInitProfiles is the environment variables used for initial profiles EnvIPFSInitProfiles = "IPFS_INIT_PROFILES" + // EnvIPFSProfiles is the environment variables used for configuration profiles after peer intialization + EnvIPFSProfiles = "IPFS_PROFILES" // EnvIPFSClusterPath is the environment variables used for ipfs-cluster-service path EnvIPFSClusterPath = "IPFS_CLUSTER_PATH"