Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update installer logic and tagged version #71

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 30 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
################################
# UI Builder #
#################################
FROM node:14.17-alpine3.13 AS client-builder

WORKDIR /ui

# cache packages in layer
COPY ui/package.json /ui/package.json
COPY ui/package-lock.json /ui/package-lock.json
RUN --mount=type=cache,target=/usr/src/app/.npm \
npm set cache /usr/src/app/.npm && \
npm ci

# build
COPY ui /ui
RUN npm run build


#################################
# Downloader for AMD64 binaries #
#################################
Expand All @@ -35,14 +16,14 @@ ARG HELM_CHECKSUM_LINUX_AMD64=2b6efaa009891d3703869f4be80ab86faa33fa83d9d5ff2f64
ARG HELM_CHECKSUM_WINDOWS_AMD64=35dc439baad85728dafd2be0edd4721ae5b770c5cf72c3adf9558b1415a9cae6

# https://www.downloadkubernetes.com/
ARG KUBECTL_VERSION=1.25.9
ARG KUBECTL_VERSION=1.29.5

# https://dl.k8s.io/v1.25.9/bin/darwin/amd64/kubectl.sha256
ARG KUBECTL_CHECKSUM_DARWIN_AMD64=a7a8af548747a6a059b0351a6b8af2ccd2c9726c650732e69059c0635cee5c6b
# https://dl.k8s.io/v1.23.4/bin/linux/amd64/kubectl.sha256
ARG KUBECTL_CHECKSUM_LINUX_AMD64=aaa5ea3b3630730d2b8a8ef3cccb14b47754602c7207c7b0717158ae83c7cb10
# https://dl.k8s.io/v1.25.9/bin/windows/amd64/kubectl.exe.sha256
ARG KUBECTL_CHECKSUM_WINDOWS_AMD64=ed404eb0c3b74341d2ff799e78f9c0352e2bbd5c1b645652de2725ec77c0a78e
# https://dl.k8s.io/v1.29.5/bin/darwin/amd64/kubectl.sha256
ARG KUBECTL_CHECKSUM_DARWIN_AMD64=395082ef84594ea4cb170d599056406ed2cf39555b53e92e0caee013c1ed5cdf
# https://dl.k8s.io/v1.29.5/bin/linux/amd64/kubectl.sha256
ARG KUBECTL_CHECKSUM_LINUX_AMD64=603c8681fc0d8609c851f9cc58bcf55eeb97e2934896e858d0232aa8d1138366
# https://dl.k8s.io/v1.29.5/bin/windows/amd64/kubectl.exe.sha256
ARG KUBECTL_CHECKSUM_WINDOWS_AMD64=8de419ccecdde90172345e7d12a63de42c217d28768d84c2398d932b44d73489

# https://github.com/epinio/epinio/releases
ARG EPINIO_VERSION=1.11.0
Expand Down Expand Up @@ -105,12 +86,12 @@ ARG HELM_CHECKSUM_DARWIN_ARM64=b60ee16847e28879ae298a20ba4672fc84f741410f438e645
ARG HELM_CHECKSUM_LINUX_ARM64=cfafbae85c31afde88c69f0e5053610c8c455826081c1b2d665d9b44c31b3759

# https://www.downloadkubernetes.com/
ARG KUBECTL_VERSION=1.25.9
ARG KUBECTL_VERSION=1.29.5

# https://dl.k8s.io/v1.25.9/bin/darwin/arm64/kubectl.sha256
ARG KUBECTL_CHECKSUM_DARWIN_ARM64=4166d293b4f58e5293363f1f91a285d929a54557bf0c1a1ae22243ef24a0f58a
# https://dl.k8s.io/v1.25.9/bin/linux/arm64/kubectl.sha256
ARG KUBECTL_CHECKSUM_LINUX_ARM64=741e65b681a22074aaf9459b57dbcef6a9e993472b3019a87f57c191bc68575f
# https://dl.k8s.io/v1.29.5/bin/darwin/arm64/kubectl.sha256
ARG KUBECTL_CHECKSUM_DARWIN_ARM64=23b09c126c0a0b71b58cc725a32cf84f1753242b3892dfd762511f2da6cce165
# https://dl.k8s.io/v1.29.5/bin/linux/arm64/kubectl.sha256
ARG KUBECTL_CHECKSUM_LINUX_ARM64=9ee9168def12ac6a6c0c6430e0f73175e756ed262db6040f8aa2121ad2c1f62e

# https://github.com/epinio/epinio/releases
ARG EPINIO_VERSION=1.11.0
Expand Down Expand Up @@ -145,6 +126,23 @@ RUN wget -nv https://github.com/epinio/epinio/releases/download/v${EPINIO_VERSIO

FROM downloader-$TARGETARCH AS downloader

################################
# UI Builder #
#################################
FROM node:14.17-alpine3.13 AS client-builder

WORKDIR /ui

# cache packages in layer
COPY ui/package.json /ui/package.json
COPY ui/package-lock.json /ui/package-lock.json
RUN --mount=type=cache,target=/usr/src/app/.npm \
npm set cache /usr/src/app/.npm && \
npm ci

# build
COPY ui /ui
RUN npm run build

#################################
# Final image #
Expand All @@ -153,7 +151,7 @@ FROM scratch

LABEL org.opencontainers.image.title="Epinio" \
org.opencontainers.image.description="Push from source to Kubernetes in one step" \
org.opencontainers.image.vendor="Rancher by SUSE" \
org.opencontainers.image.vendor="Epinio by Krumware and SUSE" \
com.docker.desktop.extension.icon="https://epinio.io/images/icon-epinio.svg" \
com.docker.extension.publisher-url="https://epinio.io" \
com.docker.extension.screenshots='[{"alt": "Epinio after Installation", "url": "https://epinio.io/images/epinio-docker-desktop-screenshot.png"}]' \
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,13 @@ To install on Rancher Desktop, use the Rancher Desktop CLI `rdctl`.
* `Dockerfile `(download CLI, 2x `ARG EPINIO_VERSION`)
* `ui/src/epinio/Installer.js` (helm chart, 1x `epinio/helm-charts/releases`)
* `ui/src/App.js` (download endpoint, 2nd `DownloadIcon`)

### Troubleshooting

If having trouble installing Epinio, you may need to install it manually.

```
helm upgrade --install epinio --create-namespace --namespace epinio --atomic --set global.domain=localdev.me https://github.com/epinio/helm-charts/releases/download/epinio-1.11.1/epinio-1.11.1.tgz
```

If you receive a "Error: no cached repo found (try 'helm repo update')" error, you may need to try `helm repo update` first.
1 change: 1 addition & 0 deletions ui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
'react'
],
rules: {
'no-unused-vars': 'off',
'no-undef': 'off',
'space-before-function-paren': [
'error',
Expand Down
18 changes: 10 additions & 8 deletions ui/src/KubernetesCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ class KubernetesCheck extends React.Component {

async check() {
try {
const result = await window.ddClient.extension.host.cli.exec('kubectl', ['get', 'nodes', '-o', 'json'])
const result = await window.ddClient.extension.host.cli.exec('kubectl', ['config', 'current-context'])

const obj = result.parseJsonObject()
if (obj.items.length < 1) {
this.setRunning(false, '', 'no nodes found in cluster')
if (result.stderr.length > 0) {
console.log(result.stderr)
}
if (result.stdout.length === 0) {
this.setRunning(false, '', 'no kube context found')
return
}

const node = obj.items[0].metadata.name
const node = result.stdout.trimEnd()
this.setRunning(true, node, '')
} catch (error) {
if (error instanceof Error) {
Expand All @@ -55,13 +57,13 @@ class KubernetesCheck extends React.Component {
}

function KubernetesOK(props) {
if (props.node === 'docker-desktop') {
if (props.node.endsWith('-desktop')) {
return null
}

return <Alert severity="info">
Kubernetes is running, however you are not connected to a Docker Desktop node.
The &quot;Install&quot; button might not work with other clusters.
Kubernetes is running, however you are not connected to a Docker Desktop or Rancher Desktop node.
The &quot;Install&quot; button might not work with other contexts.
</Alert>
}

Expand Down
60 changes: 45 additions & 15 deletions ui/src/epinio/Installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default function EpinioInstaller({
const helm = async (args) => {
const result = await window.ddClient.extension.host.cli.exec('helm', args)
console.debug(JSON.stringify(result))

if (result.stderr) {
throw Error(result?.stderr)
}
Expand Down Expand Up @@ -44,11 +43,13 @@ export default function EpinioInstaller({
if (result.includes('STATUS: uninstalling')) {
console.debug('uninstalling epinio release')

// alert('epinio not yet installed')
setInstalled(null)
} else {
setInstalled(true)
}
} catch (error) {
// alert('epinio check error' + error)
setInstalled(false)
}
}
Expand All @@ -57,23 +58,31 @@ export default function EpinioInstaller({
isEpinioInstalled()
setInterval(async () => {
await isEpinioInstalled()
}, 3000)
}, 10000)
}

async function install() {
try {
setProgress(10)
const isInstalled = await checkTraefik()
if (!isInstalled) {
const isTraefikInstalled = await checkTraefik()
// alert(`Traefik is installed ${isTraefikInstalled}`)
// todo: prompt for optional installation of traefik
if (!isTraefikInstalled) {
// alert('Traefik is not installed, installing')
await installTraefik()
}
setProgress(30)

const isCertManagerInstalled = await checkCertManager()
// alert(`CertManager is installed ${isCertManagerInstalled}`)
setProgress(40)
await installCertManager()
if (!isCertManagerInstalled) {
await installCertManager()
}
setProgress(50)

setProgress(60)
// todo: Handle repo not found and "Error: no cached repo found (try 'helm repo update')"
await installEpinio()
setProgress(100)

Expand All @@ -84,12 +93,13 @@ export default function EpinioInstaller({
onInstallationChanged(false)

let message = 'Error installing Epinio'
// todo: Fix error message reflection. It appears as though stderr is not being captured.
if (error.stderr) {
message = error.stderr
}
console.error(error)
// alert(error)

onError(message)
onError(message + '. \n' + error)
} finally {
setProgress(0)
}
Expand All @@ -101,12 +111,14 @@ export default function EpinioInstaller({
await uninstallEpinio()
setProgress(25)

// todo: prompt for optional uninstallation of cert-manager
setProgress(30)
await uninstallCertManager()
// await uninstallCertManager()
setProgress(50)

// todo: prompt for optional uninstallation of traefik
setProgress(60)
await uninstallTraefik()
// await uninstallTraefik()
setProgress(100)

onInstallationChanged(true)
Expand Down Expand Up @@ -137,40 +149,58 @@ export default function EpinioInstaller({
const installTraefik = async () => {
console.log('installing traefik chart')

await helm([
const result = await helm([
'upgrade', '--install', '--atomic', 'traefik',
'--create-namespace', '--namespace', 'ingress-traefik',
'https://traefik.github.io/charts/traefik/traefik-19.0.3.tgz'
])

// alert(JSON.stringify(result))
console.log('installed: traefik')
}

const checkCertManager = async () => {
console.log('checking traefik installation')

const result = await kubectl([
'get', 'deployment', '-A',
'-l', 'app.kubernetes.io/name=cert-manager',
'-o', 'json'
])

const isInstalled = result.items.length > 0
console.log(`cert-manager already installed: ${isInstalled}`)

return isInstalled
}

const installCertManager = async () => {
console.log('installing cert-manager chart')

await helm([
// alert('installing cert-manager')
const result = await helm([
'upgrade', '--install', '--atomic', 'cert-manager',
'--create-namespace', '--namespace', 'cert-manager',
'--set', 'installCRDs=true',
'--set', 'extraArgs[0]=--enable-certificate-owner-ref=true',
'https://charts.jetstack.io/charts/cert-manager-v1.9.1.tgz'
])

// alert(JSON.stringify(result))
console.log('installed: cert-manager')
}

const installEpinio = async () => {
console.log('installing epinio chart')

await helm([
// alert('installing epinio')
const output = await helm([
'upgrade', '--install', 'epinio',
'--create-namespace', '--namespace', 'epinio',
'--atomic',
'--set', 'global.domain=' + domain,
'https://github.com/epinio/helm-charts/releases/download/epinio-1.11.0/epinio-1.11.0.tgz'
'https://github.com/epinio/helm-charts/releases/download/epinio-1.11.1/epinio-1.11.1.tgz'
])

// alert(JSON.stringify(output))
console.log('installed: epinio')
}

Expand Down
Loading