Skip to content

Commit 36291d7

Browse files
authored
Merge pull request #50 from RobotSail/revert-image
Revert from using custom IPFS Cluster image and bump to v1.0.2
2 parents 7d52844 + 6f58e5b commit 36291d7

File tree

12 files changed

+104
-262
lines changed

12 files changed

+104
-262
lines changed

.github/workflows/validate-ipfs.yaml

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ env:
1212
OPERATOR_IMAGE: "quay.io/redhat-et-ipfs/ipfs-operator"
1313
BUNDLE_IMAGE: "quay.io/redhat-et-ipfs/ipfs-operator-bundle"
1414
TAG: "v0.0.1"
15-
IPFS_CLUSTER_K8S_IMAGE: "quay.io/redhat-et-ipfs/ipfs-cluster"
16-
CLUSTER_VERSION: v1.0.2
1715

1816

1917
jobs:
@@ -77,30 +75,10 @@ jobs:
7775
with:
7876
name: operator-bundle
7977
path: /tmp/bundle.tar
80-
81-
build-ipfs-cluster:
82-
name: build-image-ipfs-cluster
83-
runs-on: ubuntu-20.04
84-
85-
steps:
86-
- name: Checkout source
87-
uses: actions/checkout@v2
88-
89-
- name: Build IPFS Cluster Kubernetes image
90-
run: make -C ipfs-cluster-image image
91-
92-
- name: Export container image
93-
run: docker save -o /tmp/image.tar "${IPFS_CLUSTER_K8S_IMAGE}"
94-
95-
- name: Save container as artifact
96-
uses: actions/upload-artifact@v1
97-
with:
98-
name: ipfs-cluster-image
99-
path: /tmp/image.tar
10078

10179
e2e:
10280
name: End-to-end tests
103-
needs: [ build-bundle, build-operator, build-ipfs-cluster ]
81+
needs: [ build-bundle, build-operator ]
10482
runs-on: ubuntu-20.04
10583
steps:
10684
- uses: actions/checkout@v2
@@ -135,25 +113,11 @@ jobs:
135113
docker tag ${OPERATOR_IMAGE} ${OPERATOR_IMAGE}:ci-build
136114
kind load docker-image ${OPERATOR_IMAGE}:ci-build
137115
138-
- name: Load the IPFS Cluster container artifact
139-
uses: actions/download-artifact@v1
140-
with:
141-
name: ipfs-cluster-image
142-
path: /tmp
143-
144-
- name: Import the IPFS Cluster container into cluster
145-
run: |
146-
docker load -i /tmp/image.tar
147-
docker inspect ${IPFS_CLUSTER_K8S_IMAGE}
148-
docker tag ${IPFS_CLUSTER_K8S_IMAGE} ${IPFS_CLUSTER_K8S_IMAGE}:ci-build
149-
kind load docker-image "${IPFS_CLUSTER_K8S_IMAGE}:ci-build"
150-
151116
- name: Load the Operator into Kind
152117
run: |
153118
helm upgrade --install \
154119
--debug \
155120
--set image.tag="ci-build" \
156-
--set ipfsCluster.tag="ci-build" \
157121
--wait --timeout=300s \
158122
ipfs-cluster ./helm/ipfs-operator
159123
@@ -231,40 +195,3 @@ jobs:
231195
run: |
232196
echo "Pushing to ${{ env.TAG }}"
233197
docker push "${BUNDLE_IMAGE}:${{ env.TAG }}"
234-
235-
push-ipfs-cluster-image:
236-
name: Push cluster image to registry
237-
needs: e2e
238-
if: >
239-
(github.event_name == 'push' || github.event_name == 'schedule') &&
240-
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
241-
runs-on: ubuntu-20.04
242-
243-
steps:
244-
- name: Load container artifact
245-
uses: actions/download-artifact@v1
246-
with:
247-
name: ipfs-cluster-image
248-
path: /tmp
249-
250-
- name: Import container image
251-
run: |
252-
docker load -i /tmp/image.tar
253-
docker inspect "${IPFS_CLUSTER_K8S_IMAGE}"
254-
255-
- name: Login to registry
256-
# If the registry server is specified in the image name, we use that.
257-
# If the server isn't in the image name, default to docker.io
258-
run: |
259-
[[ "${BUNDLE_IMAGE}" =~ ^([^/]+)/[^/]+/[^/]+ ]] && REGISTRY="${BASH_REMATCH[1]}" || REGISTRY="docker.io"
260-
echo "Attempting docker login to: ${REGISTRY}"
261-
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin ${REGISTRY}
262-
263-
- name: Push to registry (version tag)
264-
if: >
265-
(github.event_name == 'push' || github.event_name == 'schedule') &&
266-
github.ref == 'refs/heads/main'
267-
run: |
268-
echo "Pushing to ${IPFS_CLUSTER_K8S_IMAGE}:${{ env.CLUSTER_VERSION }}"
269-
docker tag "${IPFS_CLUSTER_K8S_IMAGE}" "${IPFS_CLUSTER_K8S_IMAGE}:${{ env.CLUSTER_VERSION }}"
270-
docker push "${IPFS_CLUSTER_K8S_IMAGE}:${{ env.CLUSTER_VERSION }}"

controllers/ipfs_controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ const (
4444
// IpfsReconciler reconciles a Ipfs object.
4545
type IpfsReconciler struct {
4646
client.Client
47-
Scheme *runtime.Scheme
48-
IPFSClusterImage string
47+
Scheme *runtime.Scheme
4948
}
5049

5150
//+kubebuilder:rbac:groups=*,resources=*,verbs=get;list

controllers/scripts.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,92 @@ type configureIpfsOpts struct {
2828
}
2929

3030
var (
31+
entrypoint = `
32+
#!/bin/sh
33+
user=ipfs
34+
35+
# This is a custom entrypoint for k8s designed to connect to the bootstrap
36+
# node running in the cluster. It has been set up using a configmap to
37+
# allow changes on the fly.
38+
39+
######################################
40+
# Prints out the given message to STDOUT
41+
# with timestamped formatting.
42+
# Globals:
43+
# None
44+
# Arguments:
45+
# msg: (string) message to print
46+
# Returns:
47+
# None
48+
######################################
49+
log() {
50+
msg="$1"
51+
# get the current time
52+
time=$(date +%Y-%m-%dT%H:%M:%S%z)
53+
# print the message with printf
54+
printf "[%s] %s\n" "${time}" "${msg}"
55+
}
56+
57+
######################################
58+
# This is a custom entrypoint for k8s designed to connect to the bootstrap
59+
# node running in the cluster. It has been set up using a configmap to
60+
# allow changes on the fly.
61+
#
62+
# Globals:
63+
# BOOTSTRAP_PEER_ID (string) the peer id of the bootstrap node
64+
# BOOTSTRAP_PEER_PRIV_KEY (string) the private key of the bootstrap node
65+
# BOOTSTRAP_ADDR (string) the address of the bootstrap node
66+
# SVC_NAME (string) the name of the service to connect to
67+
######################################
68+
run_ipfs_cluster() {
69+
if [ ! -f /data/ipfs-cluster/service.json ]; then
70+
log "📰 no service.json found, creating one"
71+
ipfs-cluster-service init --consensus crdt
72+
fi
73+
74+
log "🔍 reading hostname"
75+
PEER_HOSTNAME=$(cat /proc/sys/kernel/hostname)
76+
log "starting ipfs-cluster on ${PEER_HOSTNAME}"
77+
78+
grep -q ".*-0$" /proc/sys/kernel/hostname
79+
if [ $? -eq 0 ]; then
80+
log "starting ipfs-cluster using the provided peer ID and private key"
81+
CLUSTER_ID="${BOOTSTRAP_PEER_ID}" \
82+
CLUSTER_PRIVATEKEY="${BOOTSTRAP_PEER_PRIV_KEY}" \
83+
exec ipfs-cluster-service daemon --upgrade
84+
else
85+
log "building the bootstrap address"
86+
BOOTSTRAP_ADDR="/dns4/${SVC_NAME}-0.${SVC_NAME}/tcp/9096/ipfs/${BOOTSTRAP_PEER_ID}"
87+
if [ -z "${BOOTSTRAP_ADDR}" ]; then
88+
log "no bootstrap address found, exiting"
89+
exit 1
90+
fi
91+
log "starting ipfs-cluster using the bootstrap address"
92+
# Only ipfs user can get here
93+
exec ipfs-cluster-service daemon --upgrade --bootstrap "${BOOTSTRAP_ADDR}" --leave
94+
fi
95+
}
96+
97+
for op in "${@}"; do
98+
case ${op} in
99+
"debug")
100+
log "💤 Sleeping indefinitely"
101+
sleep infinity
102+
log "✅ Done"
103+
;;
104+
"run")
105+
log "🏃 Running IPFS Cluster"
106+
run_ipfs_cluster
107+
log "✅ Done"
108+
;;
109+
*)
110+
log "😕 Operation '${op}' not defined"
111+
exit 1
112+
;;
113+
esac
114+
done
115+
`
116+
31117
// TODO: dockerize kubo and move this script to the container
32118
configureIpfs = `
33119
#!/bin/sh
@@ -136,6 +222,7 @@ func (r *IpfsReconciler) configMapScripts(
136222
Namespace: m.Namespace,
137223
},
138224
Data: map[string]string{
225+
"entrypoint.sh": entrypoint,
139226
"configure-ipfs.sh": configureBuf.String(),
140227
},
141228
}

controllers/statefulset.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const (
4141
notDNSPattern = "[[:^alnum:]]"
4242
// ipfsClusterImage Defines which container image to use when pulling IPFS Cluster.
4343
// HACK: break this up so the version is parameterized, and we can inject the image locally.
44-
ipfsClusterImage = "ipfs-cluster-k8s-image:local-build"
44+
ipfsClusterImage = "docker.io/ipfs/ipfs-cluster:1.0.2"
4545
// ipfsClusterMountPath Defines where the cluster storage volume is mounted.
4646
ipfsClusterMountPath = "/data/ipfs-cluster"
4747
// ipfsMountPath Defines where the IPFS volume is mounted.
@@ -160,10 +160,11 @@ func (r *IpfsReconciler) statefulSet(m *clusterv1alpha1.Ipfs,
160160
},
161161
{
162162
Name: "ipfs-cluster",
163-
Image: r.IPFSClusterImage,
163+
Image: ipfsClusterImage,
164164
ImagePullPolicy: corev1.PullIfNotPresent,
165165
Command: []string{
166-
"/entry.sh",
166+
"sh",
167+
"/custom/entrypoint.sh",
167168
},
168169
Args: []string{
169170
"run",

hack/run-in-kind.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ check_cmd helm docker kind
5151
# load images into kind
5252
IMAGES=(
5353
"quay.io/redhat-et-ipfs/ipfs-operator"
54-
"quay.io/redhat-et-ipfs/ipfs-cluster"
5554
)
5655

5756

@@ -78,7 +77,6 @@ fi
7877
helm upgrade --install \
7978
--debug \
8079
--set image.tag="${KIND_TAG}" \
81-
--set ipfsCluster.tag="${KIND_TAG}" \
8280
--wait --timeout=300s \
8381
ipfs-cluster ./helm/ipfs-operator
8482

helm/ipfs-operator/templates/Deployment-ipfs-operator-controller-manager.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ spec:
4141
- --health-probe-bind-address=:8081
4242
- --metrics-bind-address=127.0.0.1:8080
4343
- --leader-elect
44-
- --ipfs-cluster-image={{ include "container-image" (list . .Values.ipfsCluster) }}
4544
command:
4645
- /manager
4746
image: "{{ include "container-image" (list . .Values.image) }}"

helm/ipfs-operator/values.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,3 @@ image:
99
pullPolicy: IfNotPresent
1010
# tag value or the default
1111
tag: ""
12-
# ipfsCluster defines the values to be used for the IPFS Cluster container.
13-
ipfsCluster:
14-
repository: quay.io/redhat-et-ipfs/ipfs-cluster
15-
# tag value or the default
16-
tag: ""

ipfs-cluster-image/Dockerfile

Lines changed: 0 additions & 35 deletions
This file was deleted.

ipfs-cluster-image/Makefile

Lines changed: 0 additions & 17 deletions
This file was deleted.

ipfs-cluster-image/README.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)