Skip to content

Commit

Permalink
removing ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
enrichman committed Nov 28, 2023
1 parent 40c9d56 commit 68a62d3
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 114 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ARG KUBECTL_CHECKSUM_LINUX_AMD64=aaa5ea3b3630730d2b8a8ef3cccb14b47754602c7207c7b
ARG KUBECTL_CHECKSUM_WINDOWS_AMD64=ed404eb0c3b74341d2ff799e78f9c0352e2bbd5c1b645652de2725ec77c0a78e

# https://github.com/epinio/epinio/releases
ARG EPINIO_VERSION=1.10.0
ARG EPINIO_VERSION=1.11.0-rc1

# /darwin amd64
RUN wget -nv https://get.helm.sh/helm-v${HELM_VERSION}-darwin-amd64.tar.gz && \
Expand Down Expand Up @@ -113,7 +113,7 @@ ARG KUBECTL_CHECKSUM_DARWIN_ARM64=4166d293b4f58e5293363f1f91a285d929a54557bf0c1a
ARG KUBECTL_CHECKSUM_LINUX_ARM64=741e65b681a22074aaf9459b57dbcef6a9e993472b3019a87f57c191bc68575f

# https://github.com/epinio/epinio/releases
ARG EPINIO_VERSION=1.10.0
ARG EPINIO_VERSION=1.11.0-rc1

# /darwin arm64
RUN wget -nv https://get.helm.sh/helm-v${HELM_VERSION}-darwin-arm64.tar.gz && \
Expand Down
68 changes: 45 additions & 23 deletions ui/src/epinio/API.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,70 @@
import { Buffer } from 'buffer'

export default function EpinioClient({
apiDomain,
credentials: {
username,
password
}
}) {
const login = async (username, password) => {
console.info('EpinioClient.login')

try {
await epinio([
'login', '--trust-ca', '-u', username, '-p', password, `${apiDomain}`
])
console.info('EpinioClient.login OK')
} catch (error) {
console.error('EpinioClient.login', error)
throw error
}
}

const info = async () => {
console.log('EpinioClient.info')
return doFetch(`http://${apiDomain}/api/v1/info`)

try {
const result = await epinio(['info'])
console.info('EpinioClient.info OK', result)

// TODO parse info to get version
return { version: 'v1.11.0-rc1' }
} catch (error) {
console.error('EpinioClient.info', error)
throw error
}
}

const listApplications = async (namespace) => {
console.log('EpinioClient.listApplications')
return doFetch(`http://${apiDomain}/api/v1/namespaces/${namespace}/applications`)
}

const authHeaders = () => {
const encodedUserPass = Buffer.from(`${username}:${password}`).toString('base64')
const authHeader = `Basic ${encodedUserPass}`
const headers = new Headers()
headers.set('Authorization', authHeader)
return headers
try {
const result = await epinio([
'app', 'list', '--output', 'json'
])
console.info('EpinioClient.listApplications OK', result)
return JSON.parse(result)
} catch (error) {
console.error('EpinioClient.listApplications', error)
throw error
}
}

const doFetch = async (url) => {
console.debug('EpinioClient.call', 'executing fetch', url)

const epinio = async (args) => {
try {
const resp = await fetch(url, { headers: authHeaders() })
console.debug('EpinioClient.call', 'response', resp)

const json = await resp.json()
console.debug('EpinioClient.call', 'response JSON', json)

return json
const result = await window.ddClient.extension.host.cli.exec('epinio', args)
return result.stdout
} catch (error) {
console.error('EpinioClient.call', error)
return Error(error)
console.error(error)

if (error.stderr) {
throw Error(error.stderr)
}
throw error
}
}

return {
login,
info,
listApplications
}
Expand Down
31 changes: 2 additions & 29 deletions ui/src/epinio/Credentials.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import React from 'react'

function credsChanged(creds, update) {
return creds.username !== update.username || creds.password !== update.password
}

export function credentialsOK(creds) {
return creds && creds.username !== '-' && creds.password !== '-'
}
Expand All @@ -12,31 +8,8 @@ export function credentialsOK(creds) {
function Credentials(props) {
React.useEffect(() => {
const getCredentials = async () => {
try {
// note: `-l` returns a list, hence the `.items...`, even if only a single secret matches
const result = await window.ddClient.extension.host.cli.exec(
'kubectl',
['get', 'secret', '-n', 'epinio', '-l', 'epinio.io/role=admin', '-o', 'jsonpath={.items[0].data}']
)
result.parseJsonObject()
// Retrieval above as check that epinio is present.
// Creds hardwired, unchanged from defaults
const u = { username: 'admin', password: 'password' }
if (credsChanged(props.credentials, u)) {
props.onCredentialsChanged(u)
}
} catch (error) {
// for debugging:
// if (error instanceof Error) {
// console.error(error);
// } else {
// console.log(JSON.stringify(error));
// }
const u = { username: '-', password: '-' }
if (credsChanged(props.credentials, u)) {
props.onCredentialsChanged(u)
}
}
// TODO: hardcoded user
props.onCredentialsChanged({ username: 'admin', password: 'password' })
}
if (props.enabled) {
getCredentials()
Expand Down
39 changes: 2 additions & 37 deletions ui/src/epinio/Installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ export default function EpinioInstaller({
async function install() {
try {
setProgress(10)
await installNginx()
setProgress(25)

setProgress(30)
await installCertManager()
setProgress(50)

Expand Down Expand Up @@ -83,12 +79,8 @@ export default function EpinioInstaller({
await uninstallEpinio()
setProgress(25)

setProgress(30)
await uninstallCertManager()
setProgress(50)

setProgress(75)
await uninstallNginx()
await uninstallCertManager()
setProgress(100)

onInstallationChanged(true)
Expand All @@ -101,20 +93,6 @@ export default function EpinioInstaller({
}
}

const installNginx = async () => {
console.log('installing nginx chart')

await helm([
'upgrade', '--install', '--atomic', 'ingress-nginx',
'--create-namespace', '--namespace', 'ingress-nginx',
'https://github.com/kubernetes/ingress-nginx/releases/download/helm-chart-4.7.1/ingress-nginx-4.7.1.tgz'
])

// https://github.com/docker/for-mac/issues/4903
console.log('installed: nginx')
console.log("you might need to restart docker-desktop if localhost:443 doesn't forward to nginx")
}

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

Expand All @@ -137,9 +115,7 @@ export default function EpinioInstaller({
'--create-namespace', '--namespace', 'epinio',
'--atomic',
'--set', 'global.domain=' + domain,
'--set', 'ingress.ingressClassName=nginx',
'--set', 'ingress.nginxSSLRedirect=false',
'https://github.com/epinio/helm-charts/releases/download/epinio-1.10.0/epinio-1.10.0.tgz'
'https://github.com/epinio/helm-charts/releases/download/epinio-1.11.0-rc1/epinio-1.11.0-rc1.tgz'
])

console.log('installed: epinio')
Expand Down Expand Up @@ -167,17 +143,6 @@ export default function EpinioInstaller({
console.log('uninstalled: cert-manager')
}

const uninstallNginx = async () => {
console.log('uninstalling nginx chart')

await helm([
'uninstall', '--namespace', 'ingress-nginx',
'--wait', 'ingress-nginx'
])

console.log('uninstalled: nginx')
}

// spawn epinio status check only once
useEffect(() => {
checkEpinioStatus()
Expand Down
49 changes: 26 additions & 23 deletions ui/src/epinio/Lister.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,37 @@ export function Lister({ apiDomain, enabled, credentials }) {
useEffect(() => {
const fetchApplications = () => {
const epinioClient = EpinioClient({ apiDomain, credentials })
epinioClient.listApplications('workspace')
.then(applications => {
const t = []
epinioClient.login('admin', 'password')
.then(
epinioClient.listApplications('workspace')
.then(applications => {
const t = []

for (let i = 0; i < applications.length; i++) {
const app = applications[i]
for (let i = 0; i < applications.length; i++) {
const app = applications[i]

t[i] = {
id: app.meta.name,
state: app.status,
instances: app.configuration.instances
}
t[i] = {
id: app.meta.name,
state: app.status,
instances: app.configuration.instances
}

if (app.deployment) {
t[i].dstatus = app.deployment.status
}
if (app.deployment) {
t[i].dstatus = app.deployment.status
}

if (app.configuration.routes.length > 0) {
t[i].route = app.configuration.routes[0]
}
}
if (app.configuration.routes.length > 0) {
t[i].route = app.configuration.routes[0]
}
}

setTable(t)
})
.catch(error => {
console.error('error listing applications', error)
setTable([])
})
setTable(t)
})
.catch(error => {
console.error('error listing applications', error)
setTable([])
})
)
}

if (enabled && credentialsOK(credentials)) {
Expand Down

0 comments on commit 68a62d3

Please sign in to comment.